Skip to content

Instantly share code, notes, and snippets.

@MicTech
Last active August 29, 2015 14:22
Show Gist options
  • Save MicTech/ddd0a15249d9250a50ad to your computer and use it in GitHub Desktop.
Save MicTech/ddd0a15249d9250a50ad to your computer and use it in GitHub Desktop.
Ansible notes

Change location of hosts file

  • create your own ansible.cfg

    [defaults]  
    inventory = /path/to/hosts
    

Ping all hosts

ansible all -m ping --private-key private.pem -u ec2-user

EC2

wget https://raw.githubusercontent.com/ansible/ansible/devel/plugins/inventory/ec2.py  
wget https://raw.githubusercontent.com/ansible/ansible/devel/plugins/inventory/ec2.ini  
  • create boto config with AWS keys

    [Credentials]  
    aws_access_key_id = <here>  
    aws_secret_access_key = <here>  
    
    ansible -i ec2.py -u ec2-user <region> -m ping --private-key private.pem
    

Restart machine

ansible -i ec2.py -u ec2-user <region> -a "/sbin/reboot" -f 10 --sudo --private-key private.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment