load in members resource
continuous-integration/drone/push Build is passing Details

This commit is contained in:
decentral1se 2022-05-30 13:55:29 +02:00
parent 092a3fa07c
commit 93d516e969
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410
3 changed files with 24 additions and 4 deletions

View File

@ -6,5 +6,9 @@
# out during our test run and that is absolutely no bueno
sshd_permit_root_login: true
sshd_port: 22
members: files/members.yml
pre_tasks:
- name: Include resource variables
include_vars: "{{ members }}"
roles:
- role: autonomic.sshd

View File

@ -0,0 +1,6 @@
---
members:
- username: foobar
email: barfoo
ssh_key: "ssh-rsa foo bar@nowhere.com"
uid: 1100

View File

@ -1,4 +1,11 @@
---
- name: Ensure mandatory variables are configured
assert:
that: "{{ item }} is defined"
fail_msg: "You must define the '{{ item }}' variable"
with_items:
- members
- name: Disable root SSH login
lineinfile:
line: PermitRootLogin no
@ -14,12 +21,15 @@
regexp: "^#?PasswordAuthentication"
notify: Restart SSH
- name: Include the resource variables
include_vars: "{{ role_path }}/../../resources/{{ lookup('env', 'MEMBERS_FILE') | default('members.yml', True) }}"
- name: Include resource variables
include_vars: "{{ members }}"
tags:
# Note(d1): we already load in converge.yml so skip here
- molecule-notest
- name: Register the list of autonomic members
- name: Register the list of members
set_fact:
members_list: "{{ autonomic_members | map(attribute='username') | list | join(' ') }}"
members_list: "{{ members | map(attribute='username') | list | join(' ') }}"
- name: "Only allow logins from {{ members_list }}"
lineinfile: