ansible-instantaneous-server-communication ansible-instantaneous-server-communication Ansible ######## how to install on command and control server ============================================ First step install Ansible on your command and control server (laptop or workstation, lol). This section shows the process I used on Fedora. install system dependancy .. code-block:: bash sudo yum -y install sshpass clone the git repo and create python virtualenv .. code-block:: bash git clone git://github.com/ansible/ansible.git cd ansible virtualenv .env source the environment scripts .. code-block:: bash source ./hacking/env-setup source ./.env/bin/activate install ansible and dependencies into python virtualenv .. code-block:: bash python setup.py develop create an ansible hosts file in /etc/ansible/hosts .. code-block:: bash sudo mkdir /etc/ansible sudo vim /etc/ansible/hosts put your targets into /etc/ansible/hosts for example .. code-block:: bash 127.0.0.1 and test! .. code-block:: bash ansible all -m ping –ask-pass Ansible assumes SSH keys, but may also use passwords, which is invoked with the --ask-pass flag. Invoke the --ask-sudo-pass flag if you need to supply a sudo password. ansible configuration files By default ansible looks to /etc/ansible for its configurations. In this section we document some of the configuration files ansible works with. /etc/ansible/hosts This file lists all ansible managed hosts and group mappings. /etc/ansible/host_vars This directory may hold one YAML file for each host. These files are used to pass host specific variables. /etc/ansible/group_vars This directory may hold one YAML file for each group. These files are used to pass group specific variables. /etc/ansible/group_vars/all This is a special group that matches all hosts and groups and holds variables for all hosts. Behavioral inventory variables and parameters Sometimes you always want to set specific Ansible/SSH/settings for a host, group of hosts, or all hosts. For example, this all file causes Ansible to use the root SSH user: .. code-block:: yml ------------------------------------------------------------------------ ansible_ssh_user: root Another example declares the parameters in the hosts file itself. /etc/ansible/hosts: .. code-block:: text node1.example.com ansible_ssh_private_key_file=/home/example/.ssh/aws.pem Here is a list of other behavioral inventory parameters which may be set in a host_vars or group_vars files: http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters how to prepare remote hosts Ansible requires that remote hosts have an SSH service running, and that your public SSH key is setup. Ansible also requires that all remote hosts have Python 2.4.x and the python JSON library (python-simplejson). Python 2.6.x and above ship with JSON library in the stdlib, so nothing needs to be done if you are using a newer operating system. quick notes run arbitary commands .. code-block:: bash ansible all –ask-pass -a “uptime” get all facts .. code-block:: bash ansible all –ask-pass -m setup change the amount of parallel forks, (default is 5) .. code-block:: bash ansible all –ask-pass -f 20 -a “uptime” give path to a private key .. code-block:: bash ansible tutorial_nodes –private-key=id_rsa -m shell -a ‘free -m’