Herramientas para administradores de sistemas¶
Ansible¶
ansible: instalación¶
$ ansible --version
ansible 1.6.3
ansible: inventario¶
$ cat inventory
[ALL]
vagrant ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user=vagrant
localhost
ansible: módulos sueltos¶
$ ansible -i inventory -m ping localhost
...
$ ansible -i inventory -m setup localhost
...
$ ansible -i inventory -m ping ALL
ansible: playbook¶
$ ansible-playbook -i inventory playbook.yml
ansible: definición playbook¶
- hosts: vagrant
sudo: yes
tasks:
- name: create new user
user: name=curso state=present
- name: install apache web server
apt: name=apache2 state=present
- name: check process
shell: ps -ef | grep apache2 | wc -l
- name: copy file
template: src=id.j2 dest=/home/{{ item.user }}/.id
with_items:
- user: curso
ansible: plantillas¶
$ cat id.j2
[identity]
IP={{ ansible_all_ipv4_addresses[0] }}
name={{ item.user }}