Skip to content

Commit be3dd4f

Browse files
committed
feat(googleauth): rhel family support
1 parent 1dcd7d5 commit be3dd4f

3 files changed

Lines changed: 53 additions & 2 deletions

File tree

users/googleauth.sls

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# vim: sts=2 ts=2 sw=2 et ai
22
{%- from "users/map.jinja" import users with context %}
33
4-
{%- if not grains['os_family'] in ['RedHat', 'Suse'] %}
4+
{%- if not grains['os_family'] in ['Suse'] %}
55
users_googleauth-package:
66
pkg.installed:
77
- name: {{ users.googleauth_package }}
@@ -15,6 +15,27 @@ users_{{ users.googleauth_dir }}:
1515
- group: {{ users.root_group }}
1616
- mode: '0700'
1717
18+
{%- if grains['os_family'] == 'RedHat' %}
19+
policycoreutils-package:
20+
pkg.installed:
21+
- pkgs:
22+
- policycoreutils
23+
{%- if grains['osmajorrelease']|int <= 7 %}
24+
- policycoreutils-python
25+
{%- else %}
26+
- policycoreutils-python-utils
27+
{%- endif %}
28+
users_googleauth_selinux_present:
29+
selinux.fcontext_policy_present:
30+
- name: "{{ users.googleauth_dir }}(/.*)?"
31+
- filetype: 'a'
32+
- sel_user: unconfined_u
33+
- sel_type: ssh_home_t
34+
- sel_level: s0
35+
- require:
36+
- pkg: policycoreutils-package
37+
{%- endif %}
38+
1839
{%- for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
1940
{%- if 'google_auth' in user %}
2041
{%- for svc in user['google_auth'] %}
@@ -33,12 +54,23 @@ users_{{ users.googleauth_dir }}:
3354
users_googleauth-pam-{{ svc }}-{{ name }}:
3455
file.replace:
3556
- name: /etc/pam.d/{{ svc }}
57+
{%- if grains['os_family'] == 'RedHat' %}
58+
- pattern: '^(auth[ \t]*substack[ \t]*password-auth)'
59+
{%- else %}
3660
- pattern: '^(@include[ \t]*common-auth)'
61+
{%- endif %}
3762
- repl: '{{ repl }}\n\1'
3863
- unless: grep pam_google_authenticator.so /etc/pam.d/{{ svc }}
3964
- backup: .bak
4065
{%- endif %}
4166
{%- endfor %}
4267
{%- endif %}
4368
{%- endfor %}
69+
70+
{%- if grains['os_family'] == 'RedHat' %}
71+
users_googleauth_selinux_applied:
72+
selinux.fcontext_policy_applied:
73+
- name: {{ users.googleauth_dir }}
74+
{%- endif %}
75+
4476
{%- endif %}

users/init.sls

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ include:
5050
- users.sudo
5151
{%- endif %}
5252
{%- if used_googleauth %}
53+
{%- if grains['os_family'] == 'RedHat' %}
54+
- epel
55+
{%- endif %}
5356
- users.googleauth
5457
{%- endif %}
5558
{%- if used_user_files %}
@@ -506,7 +509,7 @@ users_{{ users.sudoers_dir }}/{{ sudoers_d_filename }}:
506509
- name: {{ users.sudoers_dir }}/{{ sudoers_d_filename }}
507510
{% endif %}
508511
509-
{%- if not grains['os_family'] in ['RedHat', 'Suse'] %}
512+
{%- if not grains['os_family'] in ['Suse'] %}
510513
{%- if 'google_auth' in user %}
511514
{%- for svc in user['google_auth'] %}
512515
users_googleauth-{{ svc }}-{{ name }}:
@@ -518,6 +521,9 @@ users_googleauth-{{ svc }}-{{ name }}:
518521
- group: {{ users.root_group }}
519522
- mode: '0600'
520523
- require:
524+
{%- if grains['os_family'] == 'RedHat' %}
525+
- pkg: epel_release
526+
{%- endif %}
521527
- pkg: users_googleauth-package
522528
{%- endfor %}
523529
{%- endif %}

users/map.jinja

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
'polkit_dir': '/etc/polkit-1/localauthority.conf.d',
3131
'polkit_defaults': 'unix-group:sudo;'
3232
},
33+
'RedHat': {
34+
'sudoers_dir': '/etc/sudoers.d',
35+
'sudoers_file': '/etc/sudoers',
36+
'googleauth_dir': '/etc/google_authenticator.d',
37+
'root_group': 'root',
38+
'shell': '/bin/bash',
39+
'visudo_shell': '/bin/bash',
40+
'bash_package': 'bash',
41+
'sudo_package': 'sudo',
42+
'googleauth_package': 'google-authenticator',
43+
'polkit_dir': '/etc/polkit-1/localauthority.conf.d',
44+
'polkit_defaults': 'unix-group:sudo;'
45+
},
3346
'Gentoo': {
3447
'sudoers_dir': '/etc/sudoers.d',
3548
'sudoers_file': '/etc/sudoers',

0 commit comments

Comments
 (0)