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
clone the git repo and create python virtualenv
source the environment scripts
install ansible and dependencies into python virtualenv
create an ansible hosts file in /etc/ansible/hosts
put your targets into /etc/ansible/hosts for example
and test!
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:
Another example declares the parameters in the hosts file itself.
/etc/ansible/hosts:
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
get all facts
change the amount of parallel forks, (default is 5)
give path to a private key
Remarkbox
Comments