Skip to content

Commit

Permalink
updated labguides for proamability fixes (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
chines-arista authored and networkRob-Arista committed Jan 30, 2024
1 parent 60887b8 commit ab202d3
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
- name: Add a VLAN
hosts: 192.168.0.14
gather_facts: 'no'
connection: local
vars:
provider:
host: "{{ ansible_host }}"
username: "arista"
password: "arista"
authorize: 'yes'
transport: httpapi
validate_certs: 'no'
ansible_user: arista
# make sure that LABPASSPHRASE is defined:
# export LABPASSPHRASE=`cat /home/coder/.config/code-server/config.yaml| grep "password:" | awk '{print $2}'`
ansible_password: "{{ lookup('env', 'LABPASSPHRASE') }}"
ansible_network_os: arista.eos.eos
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
tasks:
- eos_config:
lines:
- name foo
parents: vlan 500
provider: "{{ provider }}"
parents: vlan 500
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For the final lab, we will be playing with Ansible - both ad-hoc
additional access after the event is completed.

For some good reading, we recommend browsing the \ `Ansible
website <https://www.google.com/url?q=http://docs.ansible.com/ansible/latest/intro_getting_started.html&sa=D&ust=1523980189984000>`__\.
website <https://docs.ansible.com/ansible/latest/getting_started/index.html>`__\.

Ad-Hoc Commands
---------------
Expand Down Expand Up @@ -99,77 +99,69 @@ it’s doing:
.. cssclass:: table-hover
+-----------------------------------+--------------------------------------+
| **Command** | **Description** |
+-----------------------------------+--------------------------------------+
| ``---`` | The standard beginning of an |
| | Ansible playbook |
+-----------------------------------+--------------------------------------+
| ``- name: Add a VLAN`` | Names the task. This will be |
| | displayed at runtime. |
+-----------------------------------+--------------------------------------+
| ``hosts: 192.168.0.14`` | Defines the host(s) to run |
| | against. This is currently set to |
| | one host, but could be a group! |
+-----------------------------------+--------------------------------------+
| ``gather_facts: no`` | Don’t gather information about |
| | the device, just run the command. |
| | We do this for speed, but you may |
| | need to use it for some things |
+-----------------------------------+--------------------------------------+
| ``connection: local`` | Sets the task to run from the |
| | local machine |
+-----------------------------------+--------------------------------------+
|   ``vars:`` | Defines a variable section |
+-----------------------------------+--------------------------------------+
|     ``provider:``   | Defines a provider section |
+-----------------------------------+--------------------------------------+
|     ``host: "{{ ansible_host }}"``| Sets the host to run against as |
| | an Ansible canned variable |
| | of ``ansible_host``. This will key |
| | off ``hosts`` above. Note that |
| | Ansible variables use {{ curly |
| | brackets }} |
+-----------------------------------+--------------------------------------+
|       ``username: "arista"`` | Sets the username to ``arista`` |
+-----------------------------------+--------------------------------------+
| ``password: "{REPLACE_PWD}"`` | Sets the password to ``{REPLACE_PWD}`` |
+-----------------------------------+--------------------------------------+
|       ``authorize: yes`` | Enables once connected |
+-----------------------------------+--------------------------------------+
|       ``transport: eapi`` | Uses eAPI instead of the SSH. You |
| | can do either |
+-----------------------------------+--------------------------------------+
|       ``validate_certs: no`` | Don’t validate SSL certificates |
+-----------------------------------+--------------------------------------+
|   ``tasks:`` | Begins the ``tasks`` section |
+-----------------------------------+--------------------------------------+
|     ``- eos_config:`` | Tells Ansible to use |
| | the \ `eos_config module |
| | <http://docs.ansible |
| | .com/ansible/latest/eos_config_mo |
| | dule.html&sa=D&ust=15239801900020 |
| | 00>`__\ |
+-----------------------------------+--------------------------------------+
|        ``lines:`` | Per the ``eos_config`` module, |
| | define the configuration lines to |
| | be issued to the switch. There can |
| | be more than one! |
+-----------------------------------+--------------------------------------+
|          ``- name foo`` | The actual line to issue. Note |
| | that it starts with a -. The next |
| | line would start with another - |
+-----------------------------------+--------------------------------------+
|         ``parents: vlan 500`` | The parent of the lines above. |
| | This is important for things like |
| | interfaces or VLANs. There is |
| | always a parent above them |
+-----------------------------------+--------------------------------------+
|         ``provider: "{{ provider | Specifies the provider |
| }}"`` | (connection information). This is |
| | also a variable, and it keys in |
| | on the provider section above |
+-----------------------------------+--------------------------------------+
+-----------------------------------+-----------------------------------+
| **Command** | **Description** |
+-----------------------------------+-----------------------------------+
| ``---`` | The standard beginning of a |
| | YAML file |
+-----------------------------------+-----------------------------------+
| ``- name: Add a VLAN`` | Names the task. This will be |
| | displayed at runtime. |
+-----------------------------------+-----------------------------------+
| ``hosts: 192.168.0.14`` | Defines the host(s) to run |
| | against. This is currently set to |
| | one host, but could be a group! |
+-----------------------------------+-----------------------------------+
| ``gather_facts: no`` | Don’t gather information about |
| | the device, just run the command. |
| | We do this for speed, but you may |
| | need to use it for some things |
+-----------------------------------+-----------------------------------+
|   ``vars:`` | Defines a variable section |
+-----------------------------------+-----------------------------------+
|     ``ansible_user:``   | Sets the username to ``arista`` |
+-----------------------------------+-----------------------------------+
|     ``ansible_password`` | Sets the password. |
| | "{{ lookup('env', 'LABPASSPHRASE') }}" |
| | means that the password will be |
| | set to the value of LABPASSPHRASE |
| | env variable that must be defined |
| | in advance |
+-----------------------------------+-----------------------------------+
|     ``ansible_network_os`` | Specify the network device OS |
| | In our case Arista EOS |
+-----------------------------------+-----------------------------------+
|     ``ansible_connection: httpapi`` | Use eAPI to connect to Arista switches |
+-----------------------------------+-----------------------------------+
|     ``ansible_httpapi_port: 443`` | Use port 443 to connect |
+-----------------------------------+-----------------------------------+
|     ``ansible_httpapi_use_ssl: true`` | Connect to eAPI via HTTPS |
+-----------------------------------+-----------------------------------+
|     ``ansible_httpapi_validate_certs: false`` | Don’t validate SSL certificates |
+-----------------------------------+-----------------------------------+
|   ``tasks:`` | Begins the ``tasks`` section |
+-----------------------------------+-----------------------------------+
|     ``- eos_config:`` | Tells Ansible to use |
| | the \ `eos_config module |
| | <http://docs.ansible |
| | .com/ansible/latest/eos_config_mo |
| | dule.html&sa=D&ust=15239801900020 |
| | 00>`__\ |
+-----------------------------------+-----------------------------------+
|        ``lines:`` | Per the ``eos_config`` module, |
| | define the configuration lines to |
| | be issued to the switch. There can|
| | be more than one! |
+-----------------------------------+-----------------------------------+
|          ``- name foo`` | The actual line to issue. Note |
| | that it starts with a -. The next |
| | line would start with another - |
+-----------------------------------+-----------------------------------+
|         ``parents: vlan 500`` | The parent of the lines above. |
| | This is important for things like |
| | interfaces or VLANs. There is |
| | always a parent above them |
+-----------------------------------+-----------------------------------+

For all if of its lines, all this Ansible file is really doing is
creating a vlan named ``foo`` with an ID of ``500``. Note that while this is just
Expand All @@ -187,6 +179,8 @@ following and hit **Enter**:

.. code-block:: html

export LABPASSPHRASE=`cat /home/coder/.config/code-server/config.yaml| grep "password:" | awk '{print $2}'`
echo $LABPASSPHRASE
ansible-playbook -i labfiles/lab4/lab4-advanced-hosts labfiles/lab4/lab4-advanced-playbook.yml

It’ll look like this when it’s run:
Expand Down

0 comments on commit ab202d3

Please sign in to comment.