Skip to content

Commit 22e69bb

Browse files
committed
[minor_change] Added Playbook Optimizing documentation
- Added ACI HTTPAPI documentation - Added suppress_previous and suppress_verification documentation
1 parent c84493b commit 22e69bb

File tree

2 files changed

+154
-11
lines changed

2 files changed

+154
-11
lines changed

README.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,28 @@ Modules supporting new features introduced in ACI API in specific ACI versions m
88
*Note: This collection is not compatible with versions of Ansible before v2.8.*
99

1010
## Requirements
11+
1112
Ansible v2.14 or newer
1213

1314
## Install
15+
1416
Ansible must be installed
15-
```
17+
18+
```sh
1619
sudo pip install ansible
1720
```
1821

1922
Install the collection
20-
```
23+
24+
```sh
2125
ansible-galaxy collection install cisco.aci
2226
```
27+
2328
## Use
29+
2430
Once the collection is installed, you can use it in a playbook by specifying the full namespace path to the module, plugin and/or role.
2531

26-
```
32+
```yml
2733
- hosts: aci
2834
gather_facts: no
2935

@@ -41,33 +47,44 @@ Once the collection is installed, you can use it in a playbook by specifying the
4147
delegate_to: localhost
4248
```
4349
50+
## Optimizing Playbooks
51+
52+
To find out more about a number options available to optimize the execution of playbooks, please refer to this documentation, [Optimizing Playbooks](docs/optimizing.md).
53+
4454
## Update
55+
4556
Getting the latest/nightly collection build
4657
4758
### First Approach
59+
4860
Clone the ansible-aci repository.
49-
```
61+
62+
```sh
5063
git clone https://github.com/CiscoDevNet/ansible-aci.git
5164
```
5265

5366
Go to the ansible-aci directory
54-
```
67+
68+
```sh
5569
cd ansible-aci
5670
```
5771

5872
Pull the latest master on your aci
59-
```
73+
74+
```sh
6075
git pull origin master
6176
```
6277

6378
Build and Install a collection from source
64-
```
79+
80+
```sh
6581
ansible-galaxy collection build --force
6682
ansible-galaxy collection install cisco-aci-* --force
6783
```
6884

6985
### Second Approach
70-
Go to: https://github.com/CiscoDevNet/ansible-aci/actions
86+
87+
Go to [ansible-aci Actions](https://github.com/CiscoDevNet/ansible-aci/actions)
7188

7289
Select the latest CI build
7390

@@ -76,13 +93,14 @@ Under Artifacts download collection and unzip it using Terminal or Console.
7693
*Note: The collection file is a zip file containing a tar.gz file. We recommend using CLI because some GUI-based unarchiver might unarchive both nested archives in one go.*
7794

7895
Install the unarchived tar.gz file
79-
```
96+
97+
```sh
8098
ansible-galaxy collection install cisco-aci-1.0.0.tar.gz —-force
8199
```
82100

83-
### See Also:
101+
### See Also
84102

85-
* [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details.
103+
- [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details.
86104

87105
## Contributing to this collection
88106

docs/optimizing.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Optimizing Playbooks
2+
3+
By using all of the following optimizations together its estimated that playbook execution time can be reduced by up to 60% compared to default behavior.
4+
5+
## Using the ACI HTTPAPI plugin
6+
7+
The Ansible ACI HTTPAPI plugin instructs Ansible how to interact with an APIC's HTTP based API and execute tasks on the APIC.
8+
9+
### Benefits
10+
11+
- The ACI login credentials and ansible variables can stay in the inventory.
12+
- Logs in once and executes subsequent tasks without requiring additional logins.
13+
- Automatically refreshes a login if the token expires during the playbook.
14+
- Assists with overcoming rate limiting on logins.
15+
- Leverages APIC's high availability by allowing a list of APIC hosts to be defined as a single ansible host.
16+
17+
### Enabling the plugin
18+
19+
The httpapi plugin can be enabled by setting the following variables:
20+
21+
```ini
22+
ansible_connection=ansible.netcommon.httpapi
23+
ansible_network_os=cisco.aci.aci
24+
```
25+
26+
Instead of using `hostname`, `username` & `password` in the playbook, the following variables can be used in the inventory.
27+
28+
```ini
29+
ansible_user=admin
30+
ansible_password="SomeSecretPassword"
31+
```
32+
33+
The `ansible_host` variable can contain one or more APIC hosts separated by a comma. If multiple hosts are defined the plugin will try executing tasks on the hosts in the order listed until one completes or they all fail.
34+
35+
```ini
36+
single_apic ansible_host=apic.host
37+
cluster_apic ansible_host=apic1.host,apic2.host,apic3.host
38+
```
39+
40+
Signature-based authentication can be specified in the inventory.
41+
42+
```ini
43+
ansible_httpapi_session_key={'admin': "{{ lookup('file', 'admin.key')}}"}
44+
```
45+
46+
Note: `ansible_httpapi_session_key` takes precedence over `ansible_password`.
47+
48+
### Full Example Inventory using ACI HTTPAPI plugin
49+
50+
```ini
51+
[aci]
52+
single_apic ansible_host=apic.host
53+
cluster_apic ansible_host=apic1.host,apic2.host,apic3.host
54+
55+
[aci:vars]
56+
ansible_user=admin
57+
ansible_password="SomeSecretPassword"
58+
ansible_connection=ansible.netcommon.httpapi
59+
ansible_network_os=cisco.aci.aci
60+
```
61+
62+
## Using the `suppress_` options
63+
64+
Two options are available to users on all ACI modules to assist with optimizing playbook performance by reducing API calls. These options can increase playbook performance at the expense of suppressing some features of the modules.
65+
66+
### `suppress_previous`
67+
68+
If enabled, a GET call to check previous object state will not be sent before a POST update to APIC.
69+
70+
> [!WARNING]
71+
> This causes the previous return value to be empty. The previous state of the object will not be checked and POST update calls to APIC will contain all properties specified in the task.
72+
73+
#### `suppress_previous` Aliases
74+
75+
- `no_previous`
76+
- `ignore_previous`
77+
78+
#### `suppress_previous` Example
79+
80+
```yml
81+
- hosts: aci
82+
gather_facts: no
83+
84+
tasks:
85+
- name: Add a new EPG
86+
cisco.aci.aci_epg:
87+
tenant: production
88+
ap: intranet
89+
epg: web_epg
90+
description: Web Intranet EPG
91+
bd: prod_bd
92+
suppress_previous: true
93+
delegate_to: localhost
94+
```
95+
96+
### `suppress_verification`
97+
98+
If enabled, a verifying GET call to check current object state will not be sent after a POST call to APIC.
99+
100+
> [!WARNING]
101+
> This causes the current return value to be set to the proposed value. The current object state including default values will be unverifiable until another task executes for the same object.
102+
103+
#### `suppress_verification` Aliases
104+
105+
- `no_verification`
106+
- `no_verify`
107+
- `suppress_verify`
108+
109+
#### `suppress_verification` Example
110+
111+
```yml
112+
- hosts: aci
113+
gather_facts: no
114+
115+
tasks:
116+
- name: Add a new EPG
117+
cisco.aci.aci_epg:
118+
tenant: production
119+
ap: intranet
120+
epg: web_epg
121+
description: Web Intranet EPG
122+
bd: prod_bd
123+
suppress_verification: true
124+
delegate_to: localhost
125+
```

0 commit comments

Comments
 (0)