Why would reinstallation of ansible cause 'Attempted to read “/etc/ansible/hosts” as YAML' error
up vote
0
down vote
favorite
The salient point here is that all worked until a re-installation of the same version of ansible. (post note: re-installation turned out to be irrelevant)
# rpm -qa |grep ansible
ansible-2.3.1.0-1.el7.noarch
# ansible --version
ansible 2.3.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Jul 3 2018, 06:28:28) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28.0.1)]
The following started happening yesterday evening after I removed and reinstalled ansible while testing; everything worked well until this point. The ansible version is unchanged! The format of the hosts file, yml files and execution command is also unchanged. Anyone have an idea as to what might be causing it?
# ansible-playbook do-all.yml
ERROR! Attempted to read "/etc/ansible/hosts" as YAML: Syntax Error while loading YAML.
The error appears to have been in '/etc/ansible/hosts': line 47, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
[baremetal]
host-01
^ here
Attempted to read "/etc/ansible/hosts" as ini file: /etc/ansible/hosts:69: Expected key=value host variable assignment, got: stage-operator
# cat /etc/ansible/hosts
......
## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57
# Here's another example of host ranges, this time there are no
# leading 0s:
## db-[99:101]-node.example.com
[baremetal]
host01
host02
# cat do-all.yml
---
- include: baremetal/create-user.yml
......
# cat baremetal/create-user.yml
---
- hosts: baremetal
become_user: root
gather_facts: False
tasks:
- name: Create dev group
group:
name: dev
state: present
......
ansible
add a comment |
up vote
0
down vote
favorite
The salient point here is that all worked until a re-installation of the same version of ansible. (post note: re-installation turned out to be irrelevant)
# rpm -qa |grep ansible
ansible-2.3.1.0-1.el7.noarch
# ansible --version
ansible 2.3.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Jul 3 2018, 06:28:28) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28.0.1)]
The following started happening yesterday evening after I removed and reinstalled ansible while testing; everything worked well until this point. The ansible version is unchanged! The format of the hosts file, yml files and execution command is also unchanged. Anyone have an idea as to what might be causing it?
# ansible-playbook do-all.yml
ERROR! Attempted to read "/etc/ansible/hosts" as YAML: Syntax Error while loading YAML.
The error appears to have been in '/etc/ansible/hosts': line 47, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
[baremetal]
host-01
^ here
Attempted to read "/etc/ansible/hosts" as ini file: /etc/ansible/hosts:69: Expected key=value host variable assignment, got: stage-operator
# cat /etc/ansible/hosts
......
## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57
# Here's another example of host ranges, this time there are no
# leading 0s:
## db-[99:101]-node.example.com
[baremetal]
host01
host02
# cat do-all.yml
---
- include: baremetal/create-user.yml
......
# cat baremetal/create-user.yml
---
- hosts: baremetal
become_user: root
gather_facts: False
tasks:
- name: Create dev group
group:
name: dev
state: present
......
ansible
Please provide context around line 69 of your hosts file. I guess you've commented out some lines but not it's group, so ansible is confused about file format.
– Konstantin Suvorov
Nov 9 at 8:53
Good man Konstantin! I totally missed the '69' ref and didn't see the double entry in the file. stage-operator ansible_host=10.10.10.5 stage-operator ansible_gateway=10.10.10.1
– mickt
Nov 9 at 9:08
Must check see how this double entry appeared. Thanks again. You should throw in as answer and I'll accept.
– mickt
Nov 9 at 9:09
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The salient point here is that all worked until a re-installation of the same version of ansible. (post note: re-installation turned out to be irrelevant)
# rpm -qa |grep ansible
ansible-2.3.1.0-1.el7.noarch
# ansible --version
ansible 2.3.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Jul 3 2018, 06:28:28) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28.0.1)]
The following started happening yesterday evening after I removed and reinstalled ansible while testing; everything worked well until this point. The ansible version is unchanged! The format of the hosts file, yml files and execution command is also unchanged. Anyone have an idea as to what might be causing it?
# ansible-playbook do-all.yml
ERROR! Attempted to read "/etc/ansible/hosts" as YAML: Syntax Error while loading YAML.
The error appears to have been in '/etc/ansible/hosts': line 47, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
[baremetal]
host-01
^ here
Attempted to read "/etc/ansible/hosts" as ini file: /etc/ansible/hosts:69: Expected key=value host variable assignment, got: stage-operator
# cat /etc/ansible/hosts
......
## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57
# Here's another example of host ranges, this time there are no
# leading 0s:
## db-[99:101]-node.example.com
[baremetal]
host01
host02
# cat do-all.yml
---
- include: baremetal/create-user.yml
......
# cat baremetal/create-user.yml
---
- hosts: baremetal
become_user: root
gather_facts: False
tasks:
- name: Create dev group
group:
name: dev
state: present
......
ansible
The salient point here is that all worked until a re-installation of the same version of ansible. (post note: re-installation turned out to be irrelevant)
# rpm -qa |grep ansible
ansible-2.3.1.0-1.el7.noarch
# ansible --version
ansible 2.3.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Jul 3 2018, 06:28:28) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28.0.1)]
The following started happening yesterday evening after I removed and reinstalled ansible while testing; everything worked well until this point. The ansible version is unchanged! The format of the hosts file, yml files and execution command is also unchanged. Anyone have an idea as to what might be causing it?
# ansible-playbook do-all.yml
ERROR! Attempted to read "/etc/ansible/hosts" as YAML: Syntax Error while loading YAML.
The error appears to have been in '/etc/ansible/hosts': line 47, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
[baremetal]
host-01
^ here
Attempted to read "/etc/ansible/hosts" as ini file: /etc/ansible/hosts:69: Expected key=value host variable assignment, got: stage-operator
# cat /etc/ansible/hosts
......
## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57
# Here's another example of host ranges, this time there are no
# leading 0s:
## db-[99:101]-node.example.com
[baremetal]
host01
host02
# cat do-all.yml
---
- include: baremetal/create-user.yml
......
# cat baremetal/create-user.yml
---
- hosts: baremetal
become_user: root
gather_facts: False
tasks:
- name: Create dev group
group:
name: dev
state: present
......
ansible
ansible
edited Nov 9 at 9:36
asked Nov 9 at 8:09
mickt
125
125
Please provide context around line 69 of your hosts file. I guess you've commented out some lines but not it's group, so ansible is confused about file format.
– Konstantin Suvorov
Nov 9 at 8:53
Good man Konstantin! I totally missed the '69' ref and didn't see the double entry in the file. stage-operator ansible_host=10.10.10.5 stage-operator ansible_gateway=10.10.10.1
– mickt
Nov 9 at 9:08
Must check see how this double entry appeared. Thanks again. You should throw in as answer and I'll accept.
– mickt
Nov 9 at 9:09
add a comment |
Please provide context around line 69 of your hosts file. I guess you've commented out some lines but not it's group, so ansible is confused about file format.
– Konstantin Suvorov
Nov 9 at 8:53
Good man Konstantin! I totally missed the '69' ref and didn't see the double entry in the file. stage-operator ansible_host=10.10.10.5 stage-operator ansible_gateway=10.10.10.1
– mickt
Nov 9 at 9:08
Must check see how this double entry appeared. Thanks again. You should throw in as answer and I'll accept.
– mickt
Nov 9 at 9:09
Please provide context around line 69 of your hosts file. I guess you've commented out some lines but not it's group, so ansible is confused about file format.
– Konstantin Suvorov
Nov 9 at 8:53
Please provide context around line 69 of your hosts file. I guess you've commented out some lines but not it's group, so ansible is confused about file format.
– Konstantin Suvorov
Nov 9 at 8:53
Good man Konstantin! I totally missed the '69' ref and didn't see the double entry in the file. stage-operator ansible_host=10.10.10.5 stage-operator ansible_gateway=10.10.10.1
– mickt
Nov 9 at 9:08
Good man Konstantin! I totally missed the '69' ref and didn't see the double entry in the file. stage-operator ansible_host=10.10.10.5 stage-operator ansible_gateway=10.10.10.1
– mickt
Nov 9 at 9:08
Must check see how this double entry appeared. Thanks again. You should throw in as answer and I'll accept.
– mickt
Nov 9 at 9:09
Must check see how this double entry appeared. Thanks again. You should throw in as answer and I'll accept.
– mickt
Nov 9 at 9:09
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Answer from the comments:
Please provide context around line 69 of your hosts file.
I guess you've commented out some lines but not it's group, so ansible
is confused about file format.
Found cause of the double entry, 'cut' not applied in the following. Very odd as it was before yesterday evening. crudini --set /etc/ansible/hosts $group $host "ansible_host=$(grep $host /etc/hosts | cut -f1) ansible_gateway=$staging_gate way" On to this investigation now. :)
– mickt
Nov 9 at 9:32
For completeness, here is that cause. staging & production entries in /etc/ansible/hosts are derived from /etc/hosts. The cut failed due to spaces instead of tab between IP and hostname; cut doesn't treat them the same. Changed '/etc/hosts | cut -f1' to 'tr -s ' ' /etc/hosts | cut -d ' ' -f1' to cover all situations.
– mickt
Nov 9 at 9:54
Probably better using | awk '{print $1}'
– mickt
Nov 9 at 10:58
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Answer from the comments:
Please provide context around line 69 of your hosts file.
I guess you've commented out some lines but not it's group, so ansible
is confused about file format.
Found cause of the double entry, 'cut' not applied in the following. Very odd as it was before yesterday evening. crudini --set /etc/ansible/hosts $group $host "ansible_host=$(grep $host /etc/hosts | cut -f1) ansible_gateway=$staging_gate way" On to this investigation now. :)
– mickt
Nov 9 at 9:32
For completeness, here is that cause. staging & production entries in /etc/ansible/hosts are derived from /etc/hosts. The cut failed due to spaces instead of tab between IP and hostname; cut doesn't treat them the same. Changed '/etc/hosts | cut -f1' to 'tr -s ' ' /etc/hosts | cut -d ' ' -f1' to cover all situations.
– mickt
Nov 9 at 9:54
Probably better using | awk '{print $1}'
– mickt
Nov 9 at 10:58
add a comment |
up vote
0
down vote
accepted
Answer from the comments:
Please provide context around line 69 of your hosts file.
I guess you've commented out some lines but not it's group, so ansible
is confused about file format.
Found cause of the double entry, 'cut' not applied in the following. Very odd as it was before yesterday evening. crudini --set /etc/ansible/hosts $group $host "ansible_host=$(grep $host /etc/hosts | cut -f1) ansible_gateway=$staging_gate way" On to this investigation now. :)
– mickt
Nov 9 at 9:32
For completeness, here is that cause. staging & production entries in /etc/ansible/hosts are derived from /etc/hosts. The cut failed due to spaces instead of tab between IP and hostname; cut doesn't treat them the same. Changed '/etc/hosts | cut -f1' to 'tr -s ' ' /etc/hosts | cut -d ' ' -f1' to cover all situations.
– mickt
Nov 9 at 9:54
Probably better using | awk '{print $1}'
– mickt
Nov 9 at 10:58
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Answer from the comments:
Please provide context around line 69 of your hosts file.
I guess you've commented out some lines but not it's group, so ansible
is confused about file format.
Answer from the comments:
Please provide context around line 69 of your hosts file.
I guess you've commented out some lines but not it's group, so ansible
is confused about file format.
answered Nov 9 at 9:13
Konstantin Suvorov
35.7k43980
35.7k43980
Found cause of the double entry, 'cut' not applied in the following. Very odd as it was before yesterday evening. crudini --set /etc/ansible/hosts $group $host "ansible_host=$(grep $host /etc/hosts | cut -f1) ansible_gateway=$staging_gate way" On to this investigation now. :)
– mickt
Nov 9 at 9:32
For completeness, here is that cause. staging & production entries in /etc/ansible/hosts are derived from /etc/hosts. The cut failed due to spaces instead of tab between IP and hostname; cut doesn't treat them the same. Changed '/etc/hosts | cut -f1' to 'tr -s ' ' /etc/hosts | cut -d ' ' -f1' to cover all situations.
– mickt
Nov 9 at 9:54
Probably better using | awk '{print $1}'
– mickt
Nov 9 at 10:58
add a comment |
Found cause of the double entry, 'cut' not applied in the following. Very odd as it was before yesterday evening. crudini --set /etc/ansible/hosts $group $host "ansible_host=$(grep $host /etc/hosts | cut -f1) ansible_gateway=$staging_gate way" On to this investigation now. :)
– mickt
Nov 9 at 9:32
For completeness, here is that cause. staging & production entries in /etc/ansible/hosts are derived from /etc/hosts. The cut failed due to spaces instead of tab between IP and hostname; cut doesn't treat them the same. Changed '/etc/hosts | cut -f1' to 'tr -s ' ' /etc/hosts | cut -d ' ' -f1' to cover all situations.
– mickt
Nov 9 at 9:54
Probably better using | awk '{print $1}'
– mickt
Nov 9 at 10:58
Found cause of the double entry, 'cut' not applied in the following. Very odd as it was before yesterday evening. crudini --set /etc/ansible/hosts $group $host "ansible_host=$(grep $host /etc/hosts | cut -f1) ansible_gateway=$staging_gate way" On to this investigation now. :)
– mickt
Nov 9 at 9:32
Found cause of the double entry, 'cut' not applied in the following. Very odd as it was before yesterday evening. crudini --set /etc/ansible/hosts $group $host "ansible_host=$(grep $host /etc/hosts | cut -f1) ansible_gateway=$staging_gate way" On to this investigation now. :)
– mickt
Nov 9 at 9:32
For completeness, here is that cause. staging & production entries in /etc/ansible/hosts are derived from /etc/hosts. The cut failed due to spaces instead of tab between IP and hostname; cut doesn't treat them the same. Changed '/etc/hosts | cut -f1' to 'tr -s ' ' /etc/hosts | cut -d ' ' -f1' to cover all situations.
– mickt
Nov 9 at 9:54
For completeness, here is that cause. staging & production entries in /etc/ansible/hosts are derived from /etc/hosts. The cut failed due to spaces instead of tab between IP and hostname; cut doesn't treat them the same. Changed '/etc/hosts | cut -f1' to 'tr -s ' ' /etc/hosts | cut -d ' ' -f1' to cover all situations.
– mickt
Nov 9 at 9:54
Probably better using | awk '{print $1}'
– mickt
Nov 9 at 10:58
Probably better using | awk '{print $1}'
– mickt
Nov 9 at 10:58
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221939%2fwhy-would-reinstallation-of-ansible-cause-attempted-to-read-etc-ansible-hosts%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please provide context around line 69 of your hosts file. I guess you've commented out some lines but not it's group, so ansible is confused about file format.
– Konstantin Suvorov
Nov 9 at 8:53
Good man Konstantin! I totally missed the '69' ref and didn't see the double entry in the file. stage-operator ansible_host=10.10.10.5 stage-operator ansible_gateway=10.10.10.1
– mickt
Nov 9 at 9:08
Must check see how this double entry appeared. Thanks again. You should throw in as answer and I'll accept.
– mickt
Nov 9 at 9:09