Debian Codegraph @

ansible_collections/cisco/aci/docs/optimizing.md

raw
1 # Optimizing Playbooks
2
3 The combined use of the following optimizations can reduce playbook execution time when compared to default behavior. This reduction can be significant in some circumstances.
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 when using password-based authentication.
13 - Automatically refreshes password-based logins 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=apicUser
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]
47 > `ansible_httpapi_session_key` takes precedence over `ansible_password`.
48
49 > [!TIP]
50 > Using signature-based authentication with or without ACI HTTPAPI enabled has the same execution time benefit.
51
52 ### Full Example Inventory using ACI HTTPAPI plugin
53
54 ```ini
55 [aci]
56 single_apic ansible_host=apic.host
57 cluster_apic ansible_host=apic1.host,apic2.host,apic3.host
58
59 [aci:vars]
60 ansible_user=admin
61 ansible_password="SomeSecretPassword"
62 ansible_connection=ansible.netcommon.httpapi
63 ansible_network_os=cisco.aci.aci
64 ```
65
66 ## Using the `suppress_` options
67
68 Users of all ACI modules have two options for optimizing playbook performance by decreasing API calls. These parameters can improve playbook performance while disabling some module functionality. The goal of these suppress options is to limit the number of GET API calls to APIC, hence reducing APIC's workload and increasing playbook execution speed.
69
70 ### `suppress_previous`
71
72 If enabled, a GET call to check previous object state will not be sent before a POST update to APIC.
73
74 > [!WARNING]
75 > 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.
76
77 #### `suppress_previous` Aliases
78
79 - `no_previous`
80 - `ignore_previous`
81
82 #### `suppress_previous` Example
83
84 ```yml
85 - hosts: aci
86 gather_facts: no
87
88 tasks:
89 - name: Add a new EPG
90 cisco.aci.aci_epg:
91 tenant: production
92 ap: intranet
93 epg: web_epg
94 description: Web Intranet EPG
95 bd: prod_bd
96 suppress_previous: true
97 ```
98
99 ### `suppress_verification`
100
101 If enabled, a verifying GET call to check current object state will not be sent after a POST call to APIC.
102
103 > [!WARNING]
104 > 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.
105
106 #### `suppress_verification` Aliases
107
108 - `no_verification`
109 - `no_verify`
110 - `suppress_verify`
111 - `ignore_verify`
112 - `ignore_verification`
113
114 #### `suppress_verification` Example
115
116 ```yml
117 - hosts: aci
118 gather_facts: no
119
120 tasks:
121 - name: Add a new EPG
122 cisco.aci.aci_epg:
123 tenant: production
124 ap: intranet
125 epg: web_epg
126 description: Web Intranet EPG
127 bd: prod_bd
128 suppress_verification: true
129 ```