Skip to content

Instantly share code, notes, and snippets.

@jameswpm
Last active August 20, 2018 20:36
Show Gist options
  • Save jameswpm/3e638a02a505c8a3726f3cb65af0e31a to your computer and use it in GitHub Desktop.
Save jameswpm/3e638a02a505c8a3726f3cb65af0e31a to your computer and use it in GitHub Desktop.
Notes about ansible platform from udemy course

Ansible course in Udemy (Ansible Essentials from RedHat)

What is Ansible?

  • Automation platform
  • Use playbooks to automate tasks
  • Multi-platform
  • Open-source
  • Complete tool and not just configuration management, including app deployment and other things
  • Automation and orchestration are also possible using ansible

How ansible works?

Install it using pip pip install --user ansible

  • Playbooks are written in YAML
  • Playbooks execute modules that execute tasks, using servers and infos from inventory
  • Modules are able to execute commands and scripts but is not limited to it
  • The machine where ansible is installed is named as "control machine"

Ad-hoc commands

  • Create a hosts file with some IP address from servers
  • In the example course, a hosts file are used with some IPS from vagrant machines
  • basic ad hoc command example ansible all -i hosts -u vagrant -m setup
  • command can scalate permission (-b and become in playbooks) and also take arguments for the modules
  • The command module not necessarily use the shell from the machine

Playbooks

  • playbooks could use variables and variables have precedence that should be analyzed
  • playbooks are basically a list of tasks
  • The tasks are executed in order from top to bottom
  • playbooks can contain handlers tasks that are "played" when called in the end of another task in the task list using the argument notify
  • The playbook can contains one or more play

Roles

  • Create groups to run tasks in specific machines
  • galaxy.ansible.com for commom roles
  • ansible-galaxy init creates the roles structure
  • A single playbook can be break into peaces and put in the roles structure
  • This breaking needs to be done with attention to avoid confusing and to ensure the correct use of variables and configuration files (.j2)
  • One playbook can include calls to many other plays in different roles that will be executed in any number of servers

Ansible tower

  • A complet UI to control all Ansible parametres
  • Its possible to create a role based configuration and include permission to certain users
  • The ansible tower already have a REST API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment