mirror of https://github.com/ansible/ansible.git
* introduces platform docs
(cherry picked from commit 4f63123320
)
pull/36913/head
parent
a275a39299
commit
617659a33c
@ -0,0 +1,133 @@
|
||||
.. _eos_platform_options:
|
||||
|
||||
***************************************
|
||||
EOS Platform Options
|
||||
***************************************
|
||||
|
||||
Arista EOS supports multiple connections. This page offers details on how each connection works in Ansible 2.5 and how to use it.
|
||||
|
||||
.. contents:: Topics
|
||||
|
||||
Connections Available
|
||||
================================================================================
|
||||
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
|.. | CLI | eAPI |
|
||||
+===========================+===============================================+=========================================+
|
||||
| **Protocol** | SSH | HTTP(S) |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| | **Credentials** | | uses SSH keys / SSH-agent if present | | uses HTTPS certificates if present |
|
||||
| | | | accepts ``-u myuser -k`` if using password | | |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| **Indirect Access** | via a bastion (jump host) | via a web proxy |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| | **Connection Settings** | | ``ansible_connection: network_cli`` | | ``ansible_connection: local`` |
|
||||
| | | | | | Requires ``transport: eapi`` |
|
||||
| | | | | | in the ``provider`` dictionary |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| | **Enable Mode** | | supported - use ``ansible_become: yes`` | | supported - use ``authorize: yes`` |
|
||||
| | (Privilege Escalation) | | with ``ansible_become_method: enable`` | | and ``auth_pass:`` in the |
|
||||
| | | | and ``ansible_become_pass:`` | | ``provider`` dictionary |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| **Returned Data Format** | ``stdout[0].`` | ``stdout[0].messages[0].`` |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
|
||||
|
||||
Using CLI in Ansible 2.5
|
||||
================================================================================
|
||||
|
||||
Example CLI ``group_vars/eos.yml``
|
||||
----------------------------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
ansible_connection: network_cli
|
||||
ansible_network_os: eos
|
||||
ansible_user: myuser
|
||||
ansible_ssh_pass: !vault...
|
||||
ansible_become: yes
|
||||
ansible_become_method: enable
|
||||
ansible_become_pass: !vault...
|
||||
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
|
||||
|
||||
|
||||
- If you are using SSH keys (including an ssh-agent) you can remove the ``ansible_ssh_pass`` configuration.
|
||||
- If you are accessing your host directly (not through a bastion/jump host) you can remove the ``ansible_ssh_common_args`` configuration.
|
||||
- If you are accessing your host through a bastion/jump host, you cannot include your SSH password in the ``ProxyCommand`` directive. To prevent secrets from leaking out (for example in ``ps`` output), SSH does not support providing passwords via environment variables.
|
||||
|
||||
Example CLI Task
|
||||
----------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Backup current switch config (eos)
|
||||
eos_config:
|
||||
backup: yes
|
||||
register: backup_eos_location
|
||||
when: ansible_network_os == 'eos'
|
||||
|
||||
|
||||
|
||||
Using eAPI in Ansible 2.5
|
||||
================================================================================
|
||||
|
||||
Enabling eAPI
|
||||
-------------
|
||||
|
||||
Before you can use eAPI to connect to a switch, you must enable eAPI. To enable eAPI on a new switch via Ansible, use the ``eos_eapi`` module via the CLI connection. Set up group_vars/eos.yml just like in the CLI example above, then run a playbook task like this:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Enable eAPI
|
||||
eos_eapi:
|
||||
enable_http: yes
|
||||
enable_https: yes
|
||||
become: true
|
||||
become_method: enable
|
||||
when: ansible_network_os == 'eos'
|
||||
|
||||
You can find more options for enabling HTTP/HTTPS and local http in the :ref:`eos_eapi <eos_eapi>` module documentation.
|
||||
|
||||
Once eAPI is enabled, change your ``group_vars/eos.yml`` to use the eAPI connection.
|
||||
|
||||
Example eAPI ``group_vars/eos.yml``
|
||||
-----------------------------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
ansible_connection: local
|
||||
ansible_network_os: eos
|
||||
ansible_user: myuser
|
||||
ansible_ssh_pass: !vault...
|
||||
eapi:
|
||||
host: "{{ inventory_hostname }}"
|
||||
transport: eapi
|
||||
authorize: yes
|
||||
auth_pass: !vault...
|
||||
proxy_env:
|
||||
http_proxy: http://proxy.example.com:8080
|
||||
|
||||
- If you are accessing your host directly (not through a web proxy) you can remove the ``proxy_env`` configuration.
|
||||
- If you are accessing your host through a web proxy using ``https``, change ``http_proxy`` to ``https_proxy``.
|
||||
|
||||
|
||||
Example eAPI Task
|
||||
-----------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Backup current switch config (eos)
|
||||
eos_config:
|
||||
backup: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: backup_eos_location
|
||||
environment: "{{ proxy_env }}"
|
||||
when: ansible_network_os == 'eos'
|
||||
|
||||
In this example two variables defined in ``group_vars`` get passed to the module of the task:
|
||||
|
||||
- the ``eapi`` variable gets passed to the ``provider`` option of the module
|
||||
- the ``proxy_env`` variable gets passed to the ``environment`` option of the module
|
||||
|
||||
|
||||
.. include:: shared_snippets/SSH_warning.rst
|
@ -0,0 +1,16 @@
|
||||
.. _platform_options:
|
||||
|
||||
****************
|
||||
Platform Options
|
||||
****************
|
||||
|
||||
Some Ansible Network platforms support multiple connection types, privilege escalation, or other options. The pages in this section offer standardized guides to understanding available options on each network platform. We welcome contributions from community-maintained platforms to this section.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Platform Options
|
||||
|
||||
platform_eos
|
||||
platform_ios
|
||||
platform_junos
|
||||
platform_nxos
|
@ -0,0 +1,70 @@
|
||||
.. _ios_platform_options:
|
||||
|
||||
***************************************
|
||||
IOS Platform Options
|
||||
***************************************
|
||||
|
||||
IOS supports Enable Mode (Privilege Escalation). This page offers details on how to use Enable Mode on IOS in Ansible 2.5.
|
||||
|
||||
.. contents:: Topics
|
||||
|
||||
Connections Available
|
||||
================================================================================
|
||||
|
||||
+---------------------------+-----------------------------------------------+
|
||||
|.. | CLI |
|
||||
+===========================+===============================================+
|
||||
| **Protocol** | SSH |
|
||||
+---------------------------+-----------------------------------------------+
|
||||
| | **Credentials** | | uses SSH keys / SSH-agent if present |
|
||||
| | | | accepts ``-u myuser -k`` if using password |
|
||||
+---------------------------+-----------------------------------------------+
|
||||
| **Indirect Access** | via a bastion (jump host) |
|
||||
+---------------------------+-----------------------------------------------+
|
||||
| | **Connection Settings** | | ``ansible_connection: network_cli`` |
|
||||
| | | | |
|
||||
| | | | |
|
||||
+---------------------------+-----------------------------------------------+
|
||||
| | **Enable Mode** | | supported - use ``ansible_become: yes`` |
|
||||
| | (Privilege Escalation) | | with ``ansible_become_method: enable`` |
|
||||
| | | | and ``ansible_become_pass:`` |
|
||||
+---------------------------+-----------------------------------------------+
|
||||
| **Returned Data Format** | ``stdout[0].`` |
|
||||
+---------------------------+-----------------------------------------------+
|
||||
|
||||
For legacy playbooks, IOS still supports ``ansible_connection: local``. We recommend modernizing to use ``ansible_connection: network_cli`` as soon as possible.
|
||||
|
||||
Using CLI in Ansible 2.5
|
||||
================================================================================
|
||||
|
||||
Example CLI ``group_vars/ios.yml``
|
||||
----------------------------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
ansible_connection: network_cli
|
||||
ansible_network_os: ios
|
||||
ansible_user: myuser
|
||||
ansible_ssh_pass: !vault...
|
||||
ansible_become: yes
|
||||
ansible_become_method: enable
|
||||
ansible_become_pass: !vault...
|
||||
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
|
||||
|
||||
|
||||
- If you are using SSH keys (including an ssh-agent) you can remove the ``ansible_ssh_pass`` configuration.
|
||||
- If you are accessing your host directly (not through a bastion/jump host) you can remove the ``ansible_ssh_common_args`` configuration.
|
||||
- If you are accessing your host through a bastion/jump host, you cannot include your SSH password in the ``ProxyCommand`` directive. To prevent secrets from leaking out (for example in ``ps`` output), SSH does not support providing passwords via environment variables.
|
||||
|
||||
Example CLI Task
|
||||
----------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Backup current switch config (ios)
|
||||
ios_config:
|
||||
backup: yes
|
||||
register: backup_ios_location
|
||||
when: ansible_network_os == 'ios'
|
||||
|
||||
.. include:: shared_snippets/SSH_warning.rst
|
@ -0,0 +1,113 @@
|
||||
.. _junos_platform_options:
|
||||
|
||||
***************************************
|
||||
Junos OS Platform Options
|
||||
***************************************
|
||||
|
||||
Juniper Junos OS supports multiple connections. This page offers details on how each connection works in Ansible 2.5 and how to use it.
|
||||
|
||||
.. contents:: Topics
|
||||
|
||||
Connections Available
|
||||
================================================================================
|
||||
|
||||
+----------------------------+--------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
||||
| | | | CLI | | NETCONF |
|
||||
| | | | * ``junos_netconf`` & ``junos_command`` modules only | | * all modules except ``junos_netconf``, which enables NETCONF |
|
||||
+============================+========================================================+====================================================================================================+
|
||||
| **Protocol** | SSH | XML over SSH |
|
||||
+----------------------------+--------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
||||
| | **Credentials** | | uses SSH keys / SSH-agent if present | | uses SSH keys / SSH-agent if present |
|
||||
| | | | accepts ``-u myuser -k`` if using password | | accepts ``-u myuser -k`` if using password |
|
||||
+----------------------------+--------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
||||
| **Indirect Access** | via a bastion (jump host) | via a bastion (jump host) |
|
||||
+----------------------------+--------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
||||
| **Connection Settings** | ``ansible_connection: network_cli`` | ``ansible_connection: netconf`` |
|
||||
+----------------------------+--------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
||||
| | **Enable Mode** | | not supported by Junos OS | | not supported by Junos OS |
|
||||
| | (Privilege Escalation) | | | | |
|
||||
+----------------------------+--------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
||||
| | **Returned Data Format** | | ``stdout[0].`` | | json: ``result[0]['software-information'][0]['host-name'][0]['data'] foo lo0`` |
|
||||
| | | | | | text: ``result[1].interface-information[0].physical-interface[0].name[0].data foo lo0`` |
|
||||
| | | | | | xml: ``result[1].rpc-reply.interface-information[0].physical-interface[0].name[0].data foo lo0`` |
|
||||
+----------------------------+--------------------------------------------------------+----------------------------------------------------------------------------------------------------+
|
||||
|
||||
For legacy playbooks, Ansible still supports ``ansible_connection: local`` on all JUNOS modules. We recommend modernizing to use ``ansible_connection: netconf`` or ``ansible_connection: network_cli`` as soon as possible.
|
||||
|
||||
Using CLI in Ansible 2.5
|
||||
================================================================================
|
||||
|
||||
Example CLI ``group_vars/junos.yml``
|
||||
------------------------------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
ansible_connection: network_cli
|
||||
ansible_network_os: junos
|
||||
ansible_user: myuser
|
||||
ansible_ssh_pass: !vault...
|
||||
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
|
||||
|
||||
|
||||
- If you are using SSH keys (including an ssh-agent) you can remove the ``ansible_ssh_pass`` configuration.
|
||||
- If you are accessing your host directly (not through a bastion/jump host) you can remove the ``ansible_ssh_common_args`` configuration.
|
||||
- If you are accessing your host through a bastion/jump host, you cannot include your SSH password in the ``ProxyCommand`` directive. To prevent secrets from leaking out (for example in ``ps`` output), SSH does not support providing passwords via environment variables.
|
||||
|
||||
Example CLI Task
|
||||
----------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Backup current switch config (junos)
|
||||
junos_config:
|
||||
backup: yes
|
||||
register: backup_junos_location
|
||||
when: ansible_network_os == 'junos'
|
||||
|
||||
|
||||
Using NETCONF in Ansible 2.5
|
||||
================================================================================
|
||||
|
||||
Enabling NETCONF
|
||||
----------------
|
||||
|
||||
Before you can use NETCONF to connect to a switch, you must:
|
||||
|
||||
- install the ``ncclient`` python package on your control node(s) with ``pip install ncclient``
|
||||
- enable NETCONF on the Junos OS device(s)
|
||||
|
||||
To enable NETCONF on a new switch via Ansible, use the ``junos_netconf`` module via the CLI connection. Set up group_vars/junos.yml just like in the CLI example above, then run a playbook task like this:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Enable NETCONF
|
||||
junos_netconf:
|
||||
when: ansible_network_os == 'junos'
|
||||
|
||||
Once NETCONF is enabled, change your ``group_vars/junos.yml`` to use the NETCONF connection.
|
||||
|
||||
Example NETCONF ``group_vars/junos.yml``
|
||||
----------------------------------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
ansible_connection: netconf
|
||||
ansible_network_os: junos
|
||||
ansible_user: myuser
|
||||
ansible_ssh_pass: !vault |
|
||||
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
|
||||
|
||||
|
||||
Example NETCONF Task
|
||||
--------------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Backup current switch config (junos)
|
||||
junos_config:
|
||||
backup: yes
|
||||
register: backup_junos_location
|
||||
when: ansible_network_os == 'junos'
|
||||
|
||||
|
||||
.. include:: shared_snippets/SSH_warning.rst
|
@ -0,0 +1,125 @@
|
||||
.. _nxos_platform_options:
|
||||
|
||||
***************************************
|
||||
NXOS Platform Options
|
||||
***************************************
|
||||
|
||||
Cisco NXOS supports multiple connections. This page offers details on how each connection works in Ansible 2.5 and how to use it.
|
||||
|
||||
.. contents:: Topics
|
||||
|
||||
Connections Available
|
||||
================================================================================
|
||||
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
|.. | CLI | NX-API |
|
||||
+===========================+===============================================+=========================================+
|
||||
| **Protocol** | SSH | HTTP(S) |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| | **Credentials** | | uses SSH keys / SSH-agent if present | | uses HTTPS certificates if present |
|
||||
| | | | accepts ``-u myuser -k`` if using password | | |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| **Indirect Access** | via a bastion (jump host) | via a web proxy |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| | **Connection Settings** | | ``ansible_connection: network_cli`` | | ``ansible_connection: local`` |
|
||||
| | | | | | Requires ``transport: nxapi`` |
|
||||
| | | | | | in the ``provider`` dictionary |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| | **Enable Mode** | | not supported by NXOS | | not supported by NXOS |
|
||||
| | (Privilege Escalation) | | | |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
| **Returned Data Format** | ``stdout[0].`` | ``stdout[0].messages[0].`` |
|
||||
+---------------------------+-----------------------------------------------+-----------------------------------------+
|
||||
|
||||
|
||||
Using CLI in Ansible 2.5
|
||||
================================================================================
|
||||
|
||||
Example CLI ``group_vars/nxos.yml``
|
||||
-----------------------------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
ansible_connection: network_cli
|
||||
ansible_network_os: nxos
|
||||
ansible_user: myuser
|
||||
ansible_ssh_pass: !vault...
|
||||
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
|
||||
|
||||
|
||||
- If you are using SSH keys (including an ssh-agent) you can remove the ``ansible_ssh_pass`` configuration.
|
||||
- If you are accessing your host directly (not through a bastion/jump host) you can remove the ``ansible_ssh_common_args`` configuration.
|
||||
- If you are accessing your host through a bastion/jump host, you cannot include your SSH password in the ``ProxyCommand`` directive. To prevent secrets from leaking out (for example in ``ps`` output), SSH does not support providing passwords via environment variables.
|
||||
|
||||
Example CLI Task
|
||||
----------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Backup current switch config (nxos)
|
||||
nxos_config:
|
||||
backup: yes
|
||||
register: backup_nxos_location
|
||||
when: ansible_network_os == 'nxos'
|
||||
|
||||
|
||||
|
||||
Using NX-API in Ansible 2.5
|
||||
================================================================================
|
||||
|
||||
Enabling NX-API
|
||||
---------------
|
||||
|
||||
Before you can use NX-API to connect to a switch, you must enable NX-API. To enable NX-API on a new switch via Ansible, use the ``nxos_nxapi`` module via the CLI connection. Set up group_vars/nxos.yml just like in the CLI example above, then run a playbook task like this:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Enable NX-API
|
||||
nxos_nxapi:
|
||||
enable_http: yes
|
||||
enable_https: yes
|
||||
when: ansible_network_os == 'nxos'
|
||||
|
||||
To find out more about the options for enabling HTTP/HTTPS and local http see the :ref:`nxos_nxapi <nxos_nxapi>` module documentation.
|
||||
|
||||
Once NX-API is enabled, change your ``group_vars/nxos.yml`` to use the NX-API connection.
|
||||
|
||||
Example NX-API ``group_vars/nxos.yml``
|
||||
--------------------------------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
ansible_connection: local
|
||||
ansible_network_os: nxos
|
||||
ansible_user: myuser
|
||||
ansible_ssh_pass: !vault...
|
||||
nxapi:
|
||||
host: "{{ inventory_hostname }}"
|
||||
transport: nxapi
|
||||
proxy_env:
|
||||
http_proxy: http://proxy.example.com:8080
|
||||
|
||||
- If you are accessing your host directly (not through a web proxy) you can remove the ``proxy_env`` configuration.
|
||||
- If you are accessing your host through a web proxy using ``https``, change ``http_proxy`` to ``https_proxy``.
|
||||
|
||||
|
||||
Example NX-API Task
|
||||
-------------------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Backup current switch config (nxos)
|
||||
nxos_config:
|
||||
backup: yes
|
||||
provider: "{{ nxapi }}"
|
||||
register: backup_nxos_location
|
||||
environment: "{{ proxy_env }}"
|
||||
when: ansible_network_os == 'nxos'
|
||||
|
||||
In this example two variables defined in ``group_vars`` get passed to the module of the task:
|
||||
|
||||
- the ``nxapi`` variable gets passed to the ``provider`` option of the module
|
||||
- the ``proxy_env`` variable gets passed to the ``environment`` option of the module
|
||||
|
||||
|
||||
.. include:: shared_snippets/SSH_warning.rst
|
@ -0,0 +1,2 @@
|
||||
.. warning::
|
||||
Never store passwords in plain text. We recommend using SSH keys to authenticate SSH connections. Ansible supports ssh-agent to manage your SSH keys. If you must use passwords to authenticate SSH connections, we recommend encrypting them with :ref:`Ansible Vault <playbooks_vault>`.
|
Loading…
Reference in New Issue