Uživatelské nástroje

Nástroje pro tento web


ansible

Toto je starší verze dokumentu!


Ansible

AUTOMATION FOR EVERYONE
Deploy apps. Manage systems. Crush complexity.
Ansible helps you build a strong foundation for DevOps

Homepage: http://www.ansible.com/
Doc: http://docs.ansible.com/

https://galaxy.ansible.com/

Instalace

shell# yum install epel-release
shell# yum update
shell# yum install ansible
shell# ansible --version
shell# yum install git

Nastavení

/etc/ansible/hosts
# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
#   - Comments begin with the '#' character
#   - Blank lines are ignored
#   - Groups of hosts are delimited by [header] elements
#   - You can enter hostnames or ip addresses
#   - A hostname/ip can be a member of multiple groups
 
# Ex 1: Ungrouped hosts, specify before any group headers.
localhost       ansible_connection=local

Příkazy

Spustí se modul ping na localhostu

shell# ansible -m ping localhost
localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

Spustí se modul ping na všechny stroje v inventory se spoustou detailů

shell# ansible -m ping all -vvv
Using /etc/ansible/ansible.cfg as config file
ESTABLISH LOCAL CONNECTION FOR USER: root
localhost EXEC /bin/sh -c '( umask 22 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1463407329.4-86600338140683 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1463407329.4-86600338140683 `" )'
localhost PUT /tmp/tmpunp_l9 TO /root/.ansible/tmp/ansible-tmp-1463407329.4-86600338140683/ping
localhost EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1463407329.4-86600338140683/ping; rm -rf "/root/.ansible/tmp/ansible-tmp-1463407329.4-86600338140683/" > /dev/null 2>&1'
localhost | SUCCESS => {
    "changed": false,
    "invocation": {
        "module_args": {
            "data": null
        },
        "module_name": "ping"
    },
    "ping": "pong"
}

Spustí se modul ping s argumentem pwd na všechny stroje v inventory

shell# ansible -m shell -a pwd all
localhost | SUCCESS | rc=0 >>
/etc/ansible

Inventory

  • seznamy spravovaných počítačů
  • výchozí konfigurace v /etc/ansible/hosts
  • je možné je dynamicky generovat

Moduly

ansible.1463408589.txt.bz2 · Poslední úprava: 2023/12/26 19:13 (upraveno mimo DokuWiki)