ansible-install | ansible | ansible-ntp | ansible-rhel
make sure you’ve set up SSH without a password from the ansible system towards the target systems
see ansible-install
define hosts and groups to operate
cd /etc/ansible/ mv -i ansible.cfg ansible.cfg.dist mv -i hosts hosts.dist ansible-config init --disabled -t all > ansible.cfg.defaults.plugins ansible-config init --disabled > ansible.cfg.defaults
get rid of the warning
vi ansible.cfg [defaults] interpreter_python=auto_silent [ssh_connection] ssh_args = -F /home/USER/.ssh/config
setup your host groups – assuming ~/.ssh/config
is alright
vi hosts [servers] HOST HOST [nginx] HOST destination_ip=x.x.x.x [workstations] localhost ansible_connection=local
if we were to use FQDN:PORT instead without ~/.ssh/config, then
#FQDN:PORT ansible_user=root
check
ansible all --list-hosts
make sure your ssh client knows the fingerprints
ssh HOST #ssh HOST -p PORT -l root
as user
ls -alhF ~/.ssh/config
check accessiblity of the managed systems
ansible all -m ping
send raw commands without using Python on the remote host e.g.
ansible all -m raw -a hostname
send shell commands using Python on the remote host e.g.
ansible all -m shell -a hostname
or print a remote variable e.g.
ansible all -m shell -a 'echo $TERM'
restart nginx on a specific host – beware json output is awefully long
ansible HOST -m service -a "name=nginx state=restarted"
you can now proceed with playbooks
if you are using ClusterIt aside Ansible, this script might be useful to maintain a shared list of hosts across both tools
echo -n converting clusterit.conf to ansible hosts file... sed 's/GROUP:\(.*\)/\[\1\]/' /etc/clusterit.conf > /etc/ansible/hosts && echo done
http://docs.ansible.com/ansible/intro_getting_started.html
http://docs.ansible.com/ansible/intro_configuration.html
http://docs.ansible.com/ansible/playbooks_conditionals.html
https://serversforhackers.com/an-ansible-tutorial
http://blog.programster.org/ansible-run-a-local-script-on-remote-server/
Ansible change ssh port in playbook https://stackoverflow.com/questions/34333058/ansible-change-ssh-port-in-playbook
https://stackoverflow.com/questions/28553307/ansible-using-custom-ssh-config-file