Debian Codegraph @

ansible_collections/cisco/nxos/tests/integration/targets/nxos_hostname/tasks/main.yaml

raw symbols SCIP
1 ---
2 - name: Fetch current hostname
3 cisco.nxos.nxos_command:
4 commands: show running-config | section ^hostname
5 register: hname_result
6
7 - name: Set current hostname (default)
8 ansible.builtin.set_fact:
9 current_hostname: "switch"
10
11 - name: Set current hostname
12 ansible.builtin.set_fact:
13 current_hostname: "{{ hname_result['stdout'][0].split(' ')[1] }}"
14 when: hname_result.stdout[0] != ""
15
16 - name: Run the CLI and NX-API tests
17 block:
18 - name: Include the CLI tasks
19 ansible.builtin.include_tasks: cli.yaml
20 tags:
21 - cli.yaml
22
23 - name: Include the NX-API tasks
24 ansible.builtin.include_tasks: nxapi.yaml
25 tags:
26 - nxapi
27 always:
28 - name: Reset hostname
29 cisco.nxos.nxos_config:
30 lines: "hostname {{ current_hostname }}"
31 match: none
32 when: hname_result.stdout[0] != ""
33
34 - name: Reset hostname (default)
35 cisco.nxos.nxos_config:
36 lines: "no hostname"
37 when: hname_result.stdout[0] == ""