Ansible cheatsheet
ansible all -m ping -u fulanito --sudo
ansible all -a "/bin/echo helloo"
ansible production -a "/bin/echo helloo"
ansible -i all.ini -u ubuntu oregon -a "sudo cat /root/.bash_history /home/ubuntu/.bash_history /home/devops/.bash_history"
Ansible playbooks
eval `ssh-agent` && ssh-add
ansible-playbook \
--vault-password-file=~/.ssh/vaultpw \
-i msops.aws_ec2.yml common.yml \
--limit=tag_Name_msops_prometheus0 \
--user ubuntu \
--key-file ~/.ssh/msops-terraform-temporary-key \
-Kk
eval `ssh-agent` && ssh-add
ansible-playbook \
--vault-password-file=~/.ssh/vaultpw \
-i msops.aws_ec2.yml webservers.yml \
--key-file ~/.ssh/id_rsa \
-Kk
ansible-playbook \
--vault-password-file=~/.ssh/vaultpw \
-i cadev.aws_ec2.yml common.yml \
--limit=tag_Name_cadev_build0 \
--key-file ~/.ssh/id_rsa \
-Kk
ansible-playbook \
--vault-password-file=~/.ssh/vaultpw \
-i inventory infra0.yml \
--user druiz \
-Kk
Encryptions
ansible-vault encrypt_string \
'4e5436d5463000307a9494fbd6fc468f6341ec86' \
--name 'newrelic_licence_key' > secrets.yml
Ansible inventory
ansible-inventory -i msops.aws_ec2.yml --graph
ansible -m ping aws_ec2
ansible-inventory ansible/plugins/production/aws_ec2.yml --list
``