mkdir ansible
cd ansible
vim inventory.ini
[webservers]
IP
[all:vars]
ansible_connection=ssh
ansible_user=user_name
ansible_ssh_pass=password
ansible_port=42006
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
#ansible -m ping -i inventory.ini all
ansible -m ping -i inventory.ini webservers
localhost | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
Check connectivity between ansible and the target.
ping module checks connectivity using inventory file.
the group can be specified in the inventory file.
ansible all -m ping -v
#Using /etc/ansible/ansible.cfg as config file
localhost | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
ansible webservers -m ping
#to check connectivity manually
ssh -p 42006 username@IP
#check ssh port
sudo netstat -tnlup | grep ssh
tcp 0 0 0.0.0.0:42006 0.0.0.0:* LISTEN 1006/sshd: /usr/sbi
tcp6 0 0 :::42006 :::* LISTEN 1006/sshd: /usr/sbi
No comments:
Post a Comment