Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Platform docs #36814

Merged
merged 2 commits into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docsite/rst/network/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ For documentation on using a particular network module, consult the :doc:`list o
user_guide/network_best_practices_2.5
user_guide/network_debug_troubleshooting
user_guide/network_working_with_command_output

user_guide/platform_index
133 changes: 133 additions & 0 deletions docs/docsite/rst/network/user_guide/platform_eos.rst
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the eapi example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the close reading of the PR!

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessary, but it might be a nice quality of life improvement if this was a full playbook so that the user can just copy paste it directly to a file.

---
- hosts: eos
  tasks:
  - name: Backup current switch config (eos)
    eos_config:
      backup: yes
      provider: "{{ eapi }}"
    register: backup_eos_location
    environment: "{{ proxy_env }}"
    when: ansible_network_os == 'eos'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. Quality-of-life and ease-of-use improvements are definitely on the roadmap but not a top priority for this PR.


- 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
16 changes: 16 additions & 0 deletions docs/docsite/rst/network/user_guide/platform_index.rst
Original file line number Diff line number Diff line change
@@ -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
70 changes: 70 additions & 0 deletions docs/docsite/rst/network/user_guide/platform_ios.rst
Original file line number Diff line number Diff line change
@@ -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
113 changes: 113 additions & 0 deletions docs/docsite/rst/network/user_guide/platform_junos.rst
Original file line number Diff line number Diff line change
@@ -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