Lab 2 - Solution """""""""""""""" Mandatory ========= Create the Ansible Configuration -------------------------------- * Connect to your ``srv..lab`` as ``ansible`` user * Switch into your git repo ``/home/ansible/training`` * Create a ``ansible.cfg`` file and configure * inventory path to ``hosts`` * enable ``become`` .. code-block:: bash vi ansible.cfg # file: ansible.cfg [defaults] inventory = hosts [privilege_escalation] become = True Create a static inventory ------------------------- * Create a ``hosts`` file * add all your servers to the inventory file * web1..lab * web2..lab * db..lab .. code-block:: bash vi hosts # file: hosts web1.firstname.lab web2.firstname.lab db.firstname.lab Run some Ansible commands ------------------------- * Run ``uname -a`` on all servers * Run ``whoami`` on all servers .. code-block:: bash ansible -a "uname -a" all ansible -a "whoami" all Commit your changes ------------------- * add all files to your git repo and commit it .. code-block:: bash git add hosts git add ansible.cfg git commit -m 'added inventory and ansible config' Optional ======== Run whoami as ansible user -------------------------- .. code-block:: bash ansible -a "whoami" --become-user=ansible all Try out ansible-doc ------------------- * print out all available modules .. code-block:: bash ansible-doc -l * have a look at the ``ping`` module .. code-block:: bash ansible-doc ping Checkout the available modules ------------------------------ * http://docs.ansible.com/ansible/list_of_all_modules.html