From 08f3d86a65ea57041c49cf22cc6fc4dfc452eb2d Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 31 May 2022 07:41:55 +0200 Subject: [PATCH] loading members the new way --- molecule/default/converge.yml | 4 ++++ molecule/default/files/members.yml | 6 ++++++ tasks/main.yml | 11 +++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 molecule/default/files/members.yml diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index d7b62d6..41c291c 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -8,6 +8,10 @@ - new_hetzner_server_image: debian-10 - new_hetzner_delete_protection: false - new_hetzner_rebuild_protection: false + - members: files/members.yml + pre_tasks: + - name: Include resource variables + include_vars: "{{ members }}" tasks: - name: Run the role under test block: diff --git a/molecule/default/files/members.yml b/molecule/default/files/members.yml new file mode 100644 index 0000000..9f1aa65 --- /dev/null +++ b/molecule/default/files/members.yml @@ -0,0 +1,6 @@ +--- +members: + - username: foobar + email: barfoo + ssh_key: "ssh-rsa foo bar@nowhere.com" + uid: 1100 diff --git a/tasks/main.yml b/tasks/main.yml index 3eb1372..8f12348 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,14 +4,17 @@ that: "{{ item }} is defined" fail_msg: "You must define the '{{ item }}' variable" with_items: + - members + - new_hetzner_server_image - new_hetzner_server_name - new_hetzner_server_type - - new_hetzner_server_image - name: Include resource variables - include_vars: "{{ role_path }}/../../resources/{{ lookup('env', 'MEMBERS_FILE') | default('members.yml', True) }}" + include_vars: "{{ members }}" + tags: + - molecule-notest -# Note(decentral1se): gives root SSH access for all autonomic members +# Note(decentral1se): gives root SSH access for all members - name: Ensure all Autonomic member SSH keys are registered hcloud_ssh_key: name: "{{ item.email }}" @@ -63,7 +66,7 @@ - name: Run the add-users role on the new instance vars: - members: "../../../resources/members.yml" + members: "{{ members }}" delegate_to: root-new-instance import_role: name: autonomic.add-users