Monday, January 11, 2016

Ansible Playbook diagram how it works explain simply with colors


Ad-hoc practice


Before you start go to: cd /etc/ansible

edit your host file

then

aguy@Aguys-computer:/etc/ansible$ ansible [your_IP_Here] -m ping -f 10 -u aguy --ask-pass

The above command will ask you the password for "aguy"




This picture is how an ansible playbook works.







Click the picture to see it larger & to make it easier to follow
playbook redhat linux automation devops

I color coded the objects of the code so you can quickly identify where what is what and how ansible playbooks work.



something.yml ~ the index of the playbook ~ the start file in main directory

- name: configure and deploy the webservers and application code
  hosts: ServerGroup
  sudo: True
  remote_user: your_username_here

  roles:

    - dosomething


ansible.cfg  ~ example only - check the color chart to match the code:

# config file for ansible -- http://ansible.com/
# ==============================================

# nearly all parameters can be overridden in ansible-playbook 
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first

[defaults]

# some basic default values...

inventory      = /etc/ansible/hosts
#library        = /usr/share/my_modules/
#remote_tmp     = $HOME/.ansible/tmp
forks          = 5
#poll_interval  = 15
#sudo_user      = root
#ask_sudo_pass = True
#ask_pass      = True
#transport      = smart
#remote_port    = 22
#module_lang    = C

# plays will gather facts by default, which contain information about
# the remote system.
#
# smart - gather by default, but don't regather if already gathered
# implicit - gather by default, turn off with gather_facts: False
# explicit - do not gather by default, must say gather_facts: True

#gathering = implicit


host ~ example only ~ check color chart above 

[ServerGroup]

ServerA.example.com

123.456.789.111

ServerB.anotherWebAddress.com


main.yml ~ example only ~ check the color chart above

---
- include: dosomething.yml



dosomething.yml ~ example only ~ check the color chart above


- name: Install Apache2 and php to the target
  yum: name={{ item }} state=present
  with_items:
   - httpd
   - php
   - php-mysql
   - git
   - libsemanage-python
   - libselinux-python

- selinux: state=disabled

- name: httpd needs to start
  service: name=httpd state=started enabled=yes
file