Introduction in Ansible """"""""""""""""""""""" About Ansible ============= * **K-I-S-S** configuration management tool * invented by **Michael DeHaan** * project started in **2012** * written in **Python** * open source * **configuration as data**, not code -> no coding skills needed * human readable configuration * big community Functions ========= * configuration management tool * application deployment * orchestration tool * remote execution Architecture ============ * agentless architecture * masterless -> can run from everywhere * python is needed on the managed host * yaml definition * jinja2 template engine * a lot of modules for different tasks (packages, services, configs, ...) * idempotent -> always get the same state on the managed host * communication methods * push via ssh (recommended) * pull from SCM and run locally * manage everything local Requirements ============ Control Machine Requirements ---------------------------- * Ansible Core * Python 2.4 or later * Inventory & Config File * Ansible project Managed Node Requirements ------------------------- * SSH for push architecture * Python 2.4 or later Terminology =========== * Playbooks contain Plays * Plays contain Roles (or Tasks) * Roles contain Tasks * Tasks call Modules .. image:: /../_static/terminology.png :class: align-center First steps =========== on the Control Machine ---------------------- * Installation of Ansible * Create a user * Create a ssh-key * Rollout the ssh-key to all managed Nodes * Test SSH connection (without Ansible) * add managed nodes to inventory file * add basic configuration file ``ansible.cfg`` * run your first Ansible tests on the managed Nodes -------------------- * Create a user * add sudo rule Links ----- * http://www.ansible.com/get-started * http://www.ansible.com/how-ansible-works * http://www.ansible.com/community * http://docs.ansible.com/ansible/playbooks_intro.html#ansible-pull Installation of Ansible ======================= * from OS packages * from pip * from git .. code-block:: bash # via apt on debian/ubuntu apt-get install ansible # via yum on redhat/centos - EPEL repo needed yum install ansible # via pip pip install ansible # via github git clone https://github.com/ansible/ansible.git .. hint:: On Red Hat / Centos is the **EPEL** Channel needed. .. important:: On some distributions is not the latest Ansible version available if you install Ansible via OS package manager. In that case, use ``pip``. .. hint:: Ansible installation via ``pip`` includes no configuration file. Links ----- * http://docs.ansible.com/ansible/intro_installation.html Installation of PIP =================== On **Debian**-based Linux derivates .. code:: bash apt-get install python-pip On **RedHat**-based Linux derivates (EPEL repo needed) .. code:: bash yum install python-pip On **Mac OS X** ``pip`` will automatically be installed if you install Python by ``brew`` .. code:: bash brew install python .. hint:: In case ``brew`` cannot be found you've to install `Homebrew `_ first.