I am learning Ansible as a newbie so that i can get into the industry of IT, I am learning everything from scratch
I have two hosts - hosts 1 and 2
i am trying to create a file from host 1 to host 2 - using ansible when i do this i get the following
Error reading config file (/etc/ansible/ansible.cfg): Source contains parsing errors: ‘’
[line 4]: ’ 3 \n’
[line 5]: ’ 4 # nearly all parameters can be overridden in ansible-playbook\n’
[line 6]: ’ 5 # or with command line flags. ansible will read ANSIBLE_CONFIG,\n’
[line 7]: ’ 6 # ansible.cfg in the current working directory, .ansible.cfg in\n’
[line 8]: ’ 7 # the home directory or /etc/ansible/ansible.cfg, whichever it\n’
[line 9]: ’ 8 # finds first\n’
Do you really have line numbers in your config file?
You should watch out for line endings, as well - make sure you create these
files using Linux, don't do it on a Windows machine and copy them across...
Hi Guys sorry new to this and thanks to Antony Stone - sorry if im being dents but im determined to learn this and glad i found such a great group
so actually i did have the lines and took them out - now i am getting the following
[WARNING]: * Failed to parse /etc/ansible/hosts with yaml plugin: YAML
inventory has invalid structure, it should be a dictionary, got: <class
‘ansible.parsing.yaml.objects.AnsibleUnicode’>
[WARNING]: * Failed to parse /etc/ansible/hosts with ini plugin:
/etc/ansible/hosts:1: Expected key=value host variable assignment, got:
ubuntu2004
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match ‘all’
[WARNING]: Could not match supplied host pattern, ignoring: ubuntu2004*
Basically all i am trying to do is the following - im going through th basics
[root@sc-centos-1-2-1-build-1 ansible]# ansible ubuntu2004* -m file -a “path=/home/user1/file2.txt state=touch mode=700”
ok guys did a bit of rtfm and my format for the hosts file was in no format so i did the yaml format with colons and begnnining with all:
however no i get this
[root@sc-centos-1-2-1-build-1 ansible]# ansible ubuntu2004* -m file -a “path=/home/user1/file2.txt state=touch mode=700”
[WARNING]: Could not match supplied host pattern, ignoring: ubuntu2004*
[WARNING]: No hosts matched, nothing to do
[root@sc-centos-1-2-1-build-1 ansible]#
Instead of creating your own playbooks in a format you're not familiar with,
have you tried starting from a worked-example tutorial which guides you
through creating simple playbooks and getting used to ansible commands and
YAML formatting?
I think these docs are a good start , created the ssh key pair as i was getting a permission denied
trying it out this first command below
what is -m vyos.vyos.vyos_facts -e and ansible_network_os=vyos.vyos.vyos
ok getting the hang of it - but i have added the ssh keys from master to client
but when i run ansible -m ping all
i get the following
root@ubuntu2004:/home/ubuntu# sudo ansible -m ping linux 192.168.1.115 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to connect to the host via ssh: root@192.168.1.115: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).”,
“unreachable”: true
}
root@ubuntu2004:/home/ubuntu#
“msg”: “Failed to connect to the host via ssh: root@192.168.1.115: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).”,
“unreachable”: true
please first try to connect over ssh without asking password
I am trying to connect to my linux ubuntu and centOS VM using this IP: 13.67.227.239 & 13.89.200.76
I have this error: (/home/ansible/tutorials/chapter1/ansible.cfg): Source contains parsing errors: ‘’
[line 2]: ‘13.67.227.239\n’
[line 4]: ‘13.89.200.76\n’
You seem to have added inventory to the ansible configuration file, instead of to the inventory.
Start out with an empty configuration, and add your hosts to the inventory file.
As this is fundamental to doing anything with ansible, you may want to read https://docs.ansible.com/ansible/latest/getting_started/index.html