Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
rb:ansible [08/07/2019 15:35]
andrew [Manipulate login shell]
rb:ansible [16/09/2019 17:11] (current)
andrew [Manipulate login shell]
Line 219: Line 219:
  
  
 +====== Examples ======
  
 +Set up a hosts file for ansible with sections for each group of hosts
 +<​code>​
 +$ cat hosts-ansible.ans ​
 +[webServers]
 +amazonlinux02
 +amazonlinux03
 +
 +[databaseServers]
 +amazonlinux03 ​
 +</​code>​
 +
 +Run ansible directly (without playbook) to run remote command to install package:-
 +<​code>​
 +$ ansible -i hosts-ansible.ans -u ec2-user --sudo --private-key ansible_id_rsa webServers -a "rpm -q postfix"​
 +amazonlinux02 | SUCCESS | rc=0 >>
 +postfix-2.10.1-6.amzn2.0.1.x86_64
 +
 +amazonlinux03 | SUCCESS | rc=0 >>
 +postfix-2.10.1-6.amzn2.0.1.x86_64
 +
 +andrew@puppet:​~/​ansible$ ​
 +</​code>​

rb/ansible.txt ยท Last modified: 16/09/2019 17:11 by andrew