Ansible commands
ansible all -m ping
ansible '*' -m ping
by default all hosts exists with in the host group.
ansible all -i centos1, -m ping // This command will also work .
ansible all -m debug
ansible-doc debug
ansible all -m debug --args='msg="This is a custom message"'
ansible all -m -vvv debug --args='msg="This is a custom message" verbosity=3'
ansible all -m ping -o // displays the output in one line.
ansible centos --list-hosts
copying the ssh key
ssh coopy-id centos1
root ssh key copied
ssh centos -l root // connecting as root
/etc/ssh/sshd_config
port can be changed here after changing the port from 22 to 2222 we did the below
semanage was not there we installed it newly
semanage port -a -t ssh_port_t -p tcp 2222
we also need to open the firewall in these ports
firewall-cmd --permanent --add-port=2222/tcp // open firewall port for the same
firewall-cmd --reload
service sshd restart
ssh 0 -p 2222 //0 indicates 0.0.0.0 -- testing the port
The current connection expect the connection to on port 22 for centos1 and there for it fails except for others
lets see if we can connect from unbunt-c to centos1
telnet centos1 2222
and that says connected successfully
Now we got to ansible host file configuration and mention the new port for the system
You can also specify this way
Yaml format
Yaml to Json conversion tools are available which will help you convert the yaml file to json file.
Overight the existing varible on the command prompt
Modules














Comments
Post a Comment