Skip to content

Commit 2903223

Browse files
sjpbjovial
andauthored
Support SSSD and optionally LDAP (#438)
* support sssd configuration * make sssd-ldap optional * SSSD PR review tweaks * enable installing sssd in fatimage * install sssd and sssd-ldap packages in stackhpc fatimage * fix sssd being enabled in fatimage * bump CI image * simplify sssd-ldap package installation in fatimage * bump CI image * enable mkhomedir * add sshd role * auto enable ssh passwords if using ldap * actually run sshd role * make sshd config more flexible * add basic_users_override_sssd flag * port PR comment re. basic_users docs * add sssd-ldap package during stackhpc build only * bump CI image * add missing empty sssd group * remove deprecated & empty block_devices group * regularise common groups & everything groups template a bit * bumb CI image * sssd review comments Co-authored-by: Will Szumski <[email protected]> --------- Co-authored-by: Will Szumski <[email protected]>
1 parent a7876a6 commit 2903223

File tree

26 files changed

+188
-10
lines changed

26 files changed

+188
-10
lines changed

ansible/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ roles/*
5858
!roles/squid/**
5959
!roles/tuned/
6060
!roles/tuned/**
61+
!roles/sssd/
62+
!roles/sssd/**
63+
!roles/sshd/
64+
!roles/sshd/**
6165
!roles/compute_init/
6266
!roles/compute_init/**
6367
!roles/k3s/

ansible/bootstrap.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@
110110
policy: "{{ selinux_policy }}"
111111
register: sestatus
112112

113+
- hosts: sshd
114+
tags: sshd
115+
gather_facts: no
116+
become: yes
117+
tasks:
118+
- name: Configure sshd
119+
import_role:
120+
name: sshd
121+
113122
- hosts: dnf_repos
114123
become: yes
115124
tasks:

ansible/fatimage.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
name: freeipa
5555
tasks_from: client-install.yml
5656
when: "'freeipa_client' in group_names"
57+
- name: Install sssd
58+
import_role:
59+
name: sssd
60+
tasks_from: install.yml
61+
when: "'sssd' in group_names"
5762

5863
# - import_playbook: filesystems.yml:
5964
- name: Install nfs packages

ansible/iam.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,12 @@
4040
import_role:
4141
name: freeipa
4242
tasks_from: users.yml
43+
44+
- hosts: sssd
45+
become: yes
46+
gather_facts: no
47+
tags: sssd
48+
tasks:
49+
- name: Configure sssd
50+
import_role:
51+
name: sssd

ansible/roles/basic_users/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Role Variables
2424
- An additional key `sudo` may optionally be specified giving a string (possibly multiline) defining sudo rules to be templated.
2525
- Any other keys may present for other purposes (i.e. not used by this role).
2626
- `basic_users_groups`: Optional, default empty list. A list of mappings defining information for each group. Mapping keys/values are passed through as parameters to [ansible.builtin.group](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/group_module.html) and default values are as given there.
27+
- `basic_users_override_sssd`: Optional bool, default false. Whether to disable `sssd` when ensuring users/groups exist with this role. Permits creating local users/groups even if they clash with users provided via sssd (e.g. from LDAP). Ignored if host is not in group `sssd` as well. Note with this option active `sssd` will be stopped and restarted each time this role is run.
2728

2829
Dependencies
2930
------------

ansible/roles/basic_users/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ basic_users_userdefaults:
77
shell: "{{'/sbin/nologin' if 'control' in group_names else omit }}"
88
basic_users_users: []
99
basic_users_groups: []
10+
basic_users_override_sssd: false

ansible/roles/basic_users/tasks/main.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@
77
label: "{{ item.name }}"
88
when:
99
- "item.state | default('present') == 'absent'"
10-
10+
11+
- name: Stop sssd if required
12+
systemd:
13+
name: sssd
14+
state: stopped
15+
register: _stop_sssd
16+
when:
17+
- "'sssd' in group_names"
18+
- basic_users_override_sssd | bool
19+
1120
- name: Create groups
1221
ansible.builtin.group: "{{ item }}"
1322
loop: "{{ basic_users_groups }}"
@@ -19,6 +28,12 @@
1928
label: "{{ item.name }} [{{ item.state | default('present') }}]"
2029
register: basic_users_info
2130

31+
- name: Restart sssd if required
32+
systemd:
33+
name: sssd
34+
state: started
35+
when: _stop_sssd is changed
36+
2237
- name: Write supplied public key as authorized for SSH access
2338
authorized_key:
2439
user: "{{ item.name }}"

ansible/roles/sshd/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# sshd
2+
3+
Configure sshd.
4+
5+
## Role variables
6+
7+
- `sshd_password_authentication`: Optional bool. Whether to enable password login. Default `false`.
8+
- `sshd_conf_src`: Optional string. Path to sshd configuration template. Default is in-role template.
9+
- `sshd_conf_dest`: Optional string. Path to destination for sshd configuration file. Default is `/etc/ssh/sshd_config.d/10-ansible.conf` which overides `50-{cloud-init,redhat}` files, if present.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sshd_password_authentication: false
2+
sshd_conf_src: sshd.conf.j2
3+
sshd_conf_dest: /etc/ssh/sshd_config.d/10-ansible.conf
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- name: Restart sshd
2+
systemd:
3+
name: sshd
4+
state: restarted

0 commit comments

Comments
 (0)