2024-10-02 08:39:12 +00:00
|
|
|
- name: Fetch passwords
|
2024-02-13 09:33:14 +00:00
|
|
|
set_fact:
|
2024-10-02 08:39:12 +00:00
|
|
|
password: '{{ lookup("passwordstore", "switch/"~inventory_hostname, returnall=true, missing="empty") | from_yaml }}'
|
|
|
|
|
|
|
|
- name: Set username and password for ansible connection
|
|
|
|
set_fact:
|
|
|
|
ansible_ssh_user: '{{ password.user }}'
|
|
|
|
ansible_ssh_pass: '{{ password.pass }}'
|
2024-02-13 09:33:14 +00:00
|
|
|
|
2023-12-18 10:22:14 +00:00
|
|
|
- name: Set configuration
|
|
|
|
ansible.netcommon.cli_config:
|
2024-04-08 08:48:10 +00:00
|
|
|
config: '{{ lookup("template", "config-"~manufacturer~"-"~device_type~".j2") }}'
|
2024-09-01 08:37:11 +00:00
|
|
|
vars:
|
|
|
|
ansible_command_timeout: 60
|
|
|
|
ansible_terminal_stderr_re: [] # some errors are not actually errors
|
2023-12-18 10:22:14 +00:00
|
|
|
register: result
|
|
|
|
# These lines are not displayed by 'sho ru' and always reported as different, so ignore them.
|
2024-09-01 08:37:11 +00:00
|
|
|
changed_when: result.commands | reject('match', '^(no shutdown|no switchport access vlan|no voice vlan.*|switchport mode access|switchport mode hybrid|interface .*|no enable service web-server https?)$')
|
2023-12-18 10:22:14 +00:00
|
|
|
notify: write config
|