1--- 2- debug: msg="START junos_system netconf/basic.yaml on connection={{ ansible_connection }}" 3 4- name: setup - remove hostname 5 junos_system: 6 hostname: vsrx01 7 state: absent 8 provider: "{{ netconf }}" 9 10- name: Set hostname 11 junos_system: 12 hostname: vsrx01 13 state: present 14 provider: "{{ netconf }}" 15 register: result 16 17- name: Get running configuration 18 junos_rpc: 19 rpc: get-configuration 20 provider: "{{ netconf }}" 21 register: config 22 23- assert: 24 that: 25 - "result.changed == true" 26 - "'<host-name>vsrx01</host-name>' in config.xml" 27 28- name: Set hostname (idempotent) 29 junos_system: 30 hostname: vsrx01 31 state: present 32 provider: "{{ netconf }}" 33 register: result 34 35- assert: 36 that: 37 - "result.changed == false" 38 39- name: Deactivate hostname configuration 40 junos_system: 41 hostname: vsrx01 42 state: present 43 active: False 44 provider: "{{ netconf }}" 45 register: result 46 47- name: Get running configuration 48 junos_rpc: 49 rpc: get-configuration 50 provider: "{{ netconf }}" 51 register: config 52 53- assert: 54 that: 55 - "result.changed == true" 56 - "'<host-name inactive=\"inactive\">' in config.xml" 57 58- name: Activate hostname configuration 59 junos_system: 60 hostname: vsrx01 61 state: present 62 active: True 63 provider: "{{ netconf }}" 64 register: result 65 66- name: Get running configuration 67 junos_rpc: 68 rpc: get-configuration 69 provider: "{{ netconf }}" 70 register: config 71 72- assert: 73 that: 74 - "result.changed == true" 75 - "'<host-name>vsrx01</host-name>' in config.xml" 76 77- name: Delete hostname configuration 78 junos_system: 79 hostname: vsrx01 80 state: absent 81 provider: "{{ netconf }}" 82 register: result 83 84- assert: 85 that: 86 - "result.changed == true" 87 - "'<host-name>vsrx01</host-name>' in config.xml" 88 89- name: Teardown - set hostname 90 junos_system: 91 hostname: vsrx01 92 state: present 93 provider: "{{ netconf }}" 94 95- name: setup - remove domain name 96 junos_system: 97 domain_name: ansible.com 98 state: absent 99 provider: "{{ netconf }}" 100 101- name: Set domain name 102 junos_system: 103 domain_name: ansible.com 104 state: present 105 provider: "{{ netconf }}" 106 register: result 107 108- name: Get running configuration 109 junos_rpc: 110 rpc: get-configuration 111 provider: "{{ netconf }}" 112 register: config 113 114- assert: 115 that: 116 - "result.changed == true" 117 - "'<domain-name>ansible.com</domain-name>' in config.xml" 118 119- name: Set domain name (idempotent) 120 junos_system: 121 domain_name: ansible.com 122 state: present 123 provider: "{{ netconf }}" 124 register: result 125 126- assert: 127 that: 128 - "result.changed == false" 129 130- name: Deactivate domain name 131 junos_system: 132 domain_name: ansible.com 133 state: present 134 active: False 135 provider: "{{ netconf }}" 136 register: result 137 138- name: Get running configuration 139 junos_rpc: 140 rpc: get-configuration 141 provider: "{{ netconf }}" 142 register: config 143 144- assert: 145 that: 146 - "result.changed == true" 147 - "'<domain-name inactive=\"inactive\">' in config.xml" 148 149- name: Activate domain name 150 junos_system: 151 domain_name: ansible.com 152 state: present 153 active: True 154 provider: "{{ netconf }}" 155 register: result 156 157- name: Get running configuration 158 junos_rpc: 159 rpc: get-configuration 160 provider: "{{ netconf }}" 161 register: config 162 163- assert: 164 that: 165 - "result.changed == true" 166 - "'<domain-name>ansible.com</domain-name>' in config.xml" 167 168- name: Delete domain name 169 junos_system: 170 domain_name: ansible.com 171 state: absent 172 provider: "{{ netconf }}" 173 register: result 174 175- name: Get running configuration 176 junos_rpc: 177 rpc: get-configuration 178 provider: "{{ netconf }}" 179 register: config 180 181- assert: 182 that: 183 - "result.changed == true" 184 - "'<domain-name>ansible.com</domain-name>' not in config.xml" 185 186- name: Teardown - set domain name 187 junos_system: 188 domain_name: ansible.com 189 state: present 190 provider: "{{ netconf }}" 191 192- name: Setup - delete domain search 193 junos_system: 194 domain_search: 195 - test.com 196 - sample.com 197 state: absent 198 provider: "{{ netconf }}" 199 register: result 200 201- name: Set domain search 202 junos_system: 203 domain_search: 204 - test.com 205 - sample.com 206 state: present 207 provider: "{{ netconf }}" 208 register: result 209 210- name: Get running configuration 211 junos_rpc: 212 rpc: get-configuration 213 provider: "{{ netconf }}" 214 register: config 215 216- assert: 217 that: 218 - "result.changed == true" 219 - "'<domain-search>test.com</domain-search>' in config.xml" 220 - "'<domain-search>sample.com</domain-search>' in config.xml" 221 222- name: Set domain search (idempotency) 223 junos_system: 224 domain_search: 225 - test.com 226 - sample.com 227 state: present 228 provider: "{{ netconf }}" 229 register: result 230 231- assert: 232 that: 233 - "result.changed == false" 234 235- name: Deactivate domain search 236 junos_system: 237 domain_search: 238 - test.com 239 - sample.com 240 state: present 241 active: False 242 provider: "{{ netconf }}" 243 register: result 244 245- name: Get running configuration 246 junos_rpc: 247 rpc: get-configuration 248 provider: "{{ netconf }}" 249 register: config 250 251- assert: 252 that: 253 - "result.changed == true" 254 - "'<domain-search inactive=\"inactive\">test.com</domain-search>' in config.xml" 255 - "'<domain-search inactive=\"inactive\">sample.com</domain-search>' in config.xml" 256 257- name: Activate domain search 258 junos_system: 259 domain_search: 260 - test.com 261 - sample.com 262 state: present 263 active: True 264 provider: "{{ netconf }}" 265 register: result 266 267- name: Get running configuration 268 junos_rpc: 269 rpc: get-configuration 270 provider: "{{ netconf }}" 271 register: config 272 273- assert: 274 that: 275 - "result.changed == true" 276 - "'<domain-search>test.com</domain-search>' in config.xml" 277 - "'<domain-search>sample.com</domain-search>' in config.xml" 278 279- name: Delete domain search 280 junos_system: 281 domain_search: 282 - test.com 283 - sample.com 284 state: absent 285 provider: "{{ netconf }}" 286 register: result 287 288- name: Get running configuration 289 junos_rpc: 290 rpc: get-configuration 291 provider: "{{ netconf }}" 292 register: config 293 294- assert: 295 that: 296 - "result.changed == true" 297 - "'<domain-search>test.com</domain-search>' not in config.xml" 298 - "'<domain-search>sample.com</domain-search>' not in config.xml" 299 300- name: Setup - delete name servers 301 junos_system: 302 name_servers: 303 - 8.8.8.8 304 - 8.8.4.4 305 state: absent 306 provider: "{{ netconf }}" 307 register: result 308 309- name: Set name servers 310 junos_system: 311 name_servers: 312 - 8.8.8.8 313 - 8.8.4.4 314 state: present 315 provider: "{{ netconf }}" 316 register: result 317 318- name: Get running configuration 319 junos_rpc: 320 rpc: get-configuration 321 provider: "{{ netconf }}" 322 register: config 323 324- assert: 325 that: 326 - "result.changed == true" 327 - "'<name>8.8.8.8</name>' in config.xml" 328 - "'<name>8.8.4.4</name>' in config.xml" 329 330- name: Set name servers (idempotent) 331 junos_system: 332 name_servers: 333 - 8.8.8.8 334 - 8.8.4.4 335 state: present 336 provider: "{{ netconf }}" 337 register: result 338 339- assert: 340 that: 341 - "result.changed == false" 342 343- name: Deactivate name servers 344 junos_system: 345 name_servers: 346 - 8.8.8.8 347 - 8.8.4.4 348 state: present 349 active: False 350 provider: "{{ netconf }}" 351 register: result 352 353- name: Get running configuration 354 junos_rpc: 355 rpc: get-configuration 356 provider: "{{ netconf }}" 357 register: config 358 359- assert: 360 that: 361 - "result.changed == true" 362 - "'<name-server inactive=\"inactive\">' in config.xml" 363 364- name: Activate name servers 365 junos_system: 366 name_servers: 367 - 8.8.8.8 368 - 8.8.4.4 369 state: present 370 active: True 371 provider: "{{ netconf }}" 372 register: result 373 374- name: Get running configuration 375 junos_rpc: 376 rpc: get-configuration 377 provider: "{{ netconf }}" 378 register: config 379 380- assert: 381 that: 382 - "result.changed == true" 383 - "'<name>8.8.8.8</name>' in config.xml" 384 - "'<name>8.8.4.4</name>' in config.xml" 385 386- name: Delete name servers 387 junos_system: 388 name_servers: 389 - 8.8.8.8 390 - 8.8.4.4 391 state: absent 392 provider: "{{ netconf }}" 393 register: result 394 395- name: Get running configuration 396 junos_rpc: 397 rpc: get-configuration 398 provider: "{{ netconf }}" 399 register: config 400 401- assert: 402 that: 403 - "result.changed == true" 404 - "'<name>8.8.8.8</name>' not in config.xml" 405 - "'<name>8.8.4.4</name>' not in config.xml" 406 407- debug: msg="END junos_system netconf/basic.yaml on connection={{ ansible_connection }}" 408