Bootstrap tools/examples for Ansible infrastructure DevOps automation. Shows some of the simple concepts and also includes some Python Boto3 examples. Ansible and Python can be used together for additional host logging and control.
brew install ansible python3
apt-get install ansible python3 python3-pip
brew install virtualenv
virtualenv tempEnv
source tempEnv/bin/activate
pip3 install -r requirements.txt
python3 src/boto/get_inventory.py > hosts.txt
Update ansible config file as needed: ~/.ansible.cfg
Example:
[defaults]
host_key_checking = False
retry_files_enabled = False
private_key_file = ~/.ssh/example.pem
nocows=1
Example using AnsiblePython: Shows host info at Runtime with name from Boto3 command
Example
################################################################################
Host Details: xx.xx.xx.xx # i-12345 NAME_UL running Host: 1
IPAddress: xx.xx.xx.xx
################################################################################
Command
python3 src/ansiblePython.py -p check-w.yml -v
python3 src/ansiblePython.py -p check-top.yml -v
python3 src/ansiblePython.py -p check-disk.yml -v
ansible-playbook -i hosts.txt src/check-os.yml -u ubuntu
ansible-playbook -i hosts.txt src/check-lamp.yml -u ubuntu
ansible default -i hosts.txt -m ping -u ubuntu
ansible default -i hosts.txt -a "w" -u ubuntu
ansible default -i hosts.txt -a "ps -ef" -u ubuntu
ansible default -i hosts.txt -a "netstat -ta" -u ubuntu
ansible-playbook -i hosts.txt check-user-load.yml -u ubuntu
ansible default -m setup -u ubuntu
Use –check Use –syntax-check Use –list-hosts
Ensure Python is installed on target hosts
https://www.ansible.com
http://docs.ansible.com