maintenance:general:install_ansible
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
maintenance:general:install_ansible [2019/12/24 09:41] – ↷ Page moved from guides:howto:install_ansible to maintenance:general:install_ansible bdorlandt | maintenance:general:install_ansible [2024/07/03 12:31] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Install Ansible ====== | ||
+ | > NOTE: This install guide is is meant for adding Ansible to Centos6. | ||
+ | |||
+ | Login the NetYCE terminal and execute the following steps. | ||
+ | ===== Install Python 2.7 ===== | ||
+ | < | ||
+ | sudo yum update | ||
+ | cd /tmp | ||
+ | sudo wget https:// | ||
+ | sudo tar xzf Python-2.7.16.tgz | ||
+ | cd Python-2.7.16 | ||
+ | sudo ./configure --enable-optimizations | ||
+ | sudo make altinstall | ||
+ | sudo / | ||
+ | sudo ln -s / | ||
+ | sudo rm / | ||
+ | sudo rm / | ||
+ | </ | ||
+ | |||
+ | ===== Install Pip ===== | ||
+ | < | ||
+ | sudo curl " | ||
+ | sudo / | ||
+ | </ | ||
+ | |||
+ | ===== Install Netconf plugins/ | ||
+ | < | ||
+ | sudo yum install libxslt | ||
+ | sudo yum install libxml2 | ||
+ | sudo / | ||
+ | sudo / | ||
+ | </ | ||
+ | |||
+ | ===== Install Ansible ===== | ||
+ | < | ||
+ | sudo rpm -ivh http:// | ||
+ | sudo yum update | ||
+ | sudo yum install ansible -y | ||
+ | ansible --version | ||
+ | </ | ||
+ | |||
+ | ===== Ansible EXAMPLE Template ===== | ||
+ | |||
+ | **Template name:** ansible_reachable_test | ||
+ | |||
+ | Required variables to let ansible work with python 2.7: | ||
+ | * ansible_python_interpreter: | ||
+ | |||
+ | < | ||
+ | - name: check reachable hosts | ||
+ | hosts: all | ||
+ | gather_facts: | ||
+ | vars: | ||
+ | ansible_python_interpreter: | ||
+ | cli: | ||
+ | username: < | ||
+ | password: < | ||
+ | tasks: | ||
+ | - command: ping -c1 \{\{ inventory_hostname \}\} | ||
+ | delegate_to: | ||
+ | register: ping_result | ||
+ | ignore_errors: | ||
+ | - group_by: key=reachable | ||
+ | when: ping_result|success | ||
+ | </ | ||
+ | ===== Ansible Scenario ===== | ||
+ | |||
+ | ** Ansible_cmd_job ** | ||
+ | < | ||
+ | Description < | ||
+ | |||
+ | # Test whether node is live and reachable | ||
+ | Reachable -n < | ||
+ | if < | ||
+ | | ||
+ | stop | ||
+ | endif | ||
+ | Log_action -n < | ||
+ | |||
+ | # Create ansible yml file | ||
+ | config_create -n < | ||
+ | |||
+ | # Execute ansible command job | ||
+ | ansible_exec -n < | ||
+ | if < | ||
+ | Log_action -n < | ||
+ | stop | ||
+ | endif | ||
+ | Log_action -n < | ||
+ | </ | ||
+ | |||
+ | ===== Ansible Commandjob ===== | ||
+ | **Commands: | ||
+ | < | ||
+ | # View your template | ||
+ | {< | ||
+ | </ | ||
+ | |||
+ | **Scenario: | ||
+ | < | ||
+ | [parameters] | ||
+ | template = ansible_reachable_test | ||
+ | |||
+ | |||
+ | [scenario] | ||
+ | Description < | ||
+ | task = Ansible_cmd_job | ||
+ | |||
+ | end | ||
+ | </ |