summaryrefslogtreecommitdiff
path: root/docs/automation
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2021-03-19 00:03:37 +0700
committerGitHub <noreply@github.com>2021-03-19 00:03:37 +0700
commit822ae8369cf1aa30dc49d0c03b7e60f812da195e (patch)
treedad30a25d4e3e09b5c8f19416ea583de60ae2a77 /docs/automation
parente41026efe8e03e1e30bc8d13b134fd26c9f7f6fc (diff)
parentdd44f8939b4d312e20723c58cced66cc0edcdc4f (diff)
downloadvyos-documentation-822ae8369cf1aa30dc49d0c03b7e60f812da195e.tar.gz
vyos-documentation-822ae8369cf1aa30dc49d0c03b7e60f812da195e.zip
Merge pull request #479 from sever-sever/ansible
Add ansible to doc
Diffstat (limited to 'docs/automation')
-rw-r--r--docs/automation/index.rst2
-rw-r--r--docs/automation/vyos-ansible.rst91
2 files changed, 92 insertions, 1 deletions
diff --git a/docs/automation/index.rst b/docs/automation/index.rst
index c19d819b..935748d0 100644
--- a/docs/automation/index.rst
+++ b/docs/automation/index.rst
@@ -3,7 +3,6 @@ VyOS Automation
###############
- * Ansible
* Saltstack
* startup scripts
@@ -12,4 +11,5 @@ VyOS Automation
:maxdepth: 1
vyos-api
+ vyos-ansible
command-scripting \ No newline at end of file
diff --git a/docs/automation/vyos-ansible.rst b/docs/automation/vyos-ansible.rst
new file mode 100644
index 00000000..a199152f
--- /dev/null
+++ b/docs/automation/vyos-ansible.rst
@@ -0,0 +1,91 @@
+.. _vyos-ansible:
+
+Ansible
+=======
+
+VyOS supports configuration via ansible.
+Need to install ``ansible`` and ``python3-paramiko`` module
+
+Structure of files
+
+.. code-block:: none
+
+ .
+ ├── ansible.cfg
+ ├── files
+ │   └── id_rsa_docker.pub
+ ├── hosts
+ └── main.yml
+
+
+File contents
+-------------
+
+ansible.cfg
+
+.. code-block:: none
+
+ [defaults]
+ host_key_checking = no
+ retry_files_enabled = False
+ ANSIBLE_INVENTORY_UNPARSED_FAILED = true
+
+id_rsa_docker.pub. Needs to declare only public key exactly.
+
+.. code-block:: none
+
+ AAAAB3NzaC1yc2EAAAADAQABAAABAQCoDgfhQJuJRFWJijHn7ZinZ3NWp4hWVrt7HFcvn0kgtP/5PeCtMt
+
+
+hosts
+
+.. code-block:: none
+
+ [vyos_hosts]
+ r11 ansible_ssh_host=192.0.2.11
+
+ [vyos_hosts:vars]
+ ansible_python_interpreter=/usr/bin/python3
+ ansible_user=vyos
+ ansible_ssh_pass=vyos
+ ansible_network_os=vyos
+ ansible_connection=network_cli
+
+main.yml
+
+.. code-block:: none
+
+ ---
+
+ - hosts: r11
+
+ connection: network_cli
+ gather_facts: 'no'
+
+ tasks:
+ - name: Configure remote r11
+ vyos_config:
+ lines:
+ - set system host-name r11
+ - set system name-server 203.0.113.254
+ - set service ssh disable-host-validation
+ - set system login user vyos authentication public-keys docker@work type ssh-rsa
+ - set system login user vyos authentication public-keys docker@work key "{{ lookup('file', 'id_rsa_docker.pub') }}"
+ - set system time-zone America/Los_Angeles
+ - set interfaces ethernet eth0 description WAN
+
+Run ansible
+-----------
+
+.. code-block:: none
+
+ $ ansible-playbook -i hosts main.yml
+
+ PLAY [r11] ******************************************************************************************************************************************************************************************************
+
+ TASK [Configure remote r11] *************************************************************************************************************************************************************************************
+ changed: [r11]
+
+ PLAY RECAP *****************************************************************************************************************************************************************************************************
+ r11 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
+