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
......









share|improve this question
























  • 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















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
......









share|improve this question
























  • 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













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
......









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












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.







share|improve this answer





















  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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.







share|improve this answer





















  • 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















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.







share|improve this answer





















  • 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













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.







share|improve this answer












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.








share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini