From e51d08c07324824bed25b62ee531614a4da4e0fc Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 2 Oct 2024 10:39:12 +0200 Subject: [PATCH] access: get switch username from password store --- roles/access/tasks/main.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/access/tasks/main.yml b/roles/access/tasks/main.yml index 4813ea5..3e82132 100644 --- a/roles/access/tasks/main.yml +++ b/roles/access/tasks/main.yml @@ -1,6 +1,11 @@ -- name: Get switch password +- name: Fetch passwords set_fact: - ansible_ssh_pass: '{{ lookup("passwordstore", "switch/"~inventory_hostname, subkey="pass") }}' + 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 }}' - name: Set configuration ansible.netcommon.cli_config: