Files
ansible-role-auth-duo/tasks/main.yml

73 lines
1.8 KiB
YAML
Raw Normal View History

2020-04-01 11:20:57 +13:00
---
# tasks file for auth_duo
- name: Include repository install
include_tasks: duo-repo.yml
when: auth_duo_install_repo
- name: Ensure duo is installed
yum:
name: duo_unix
enablerepo: "{{ auth_duo_reponame }}"
state: installed
# - name: Ensure ikey is populated
# fail:
# msg: "ikey should not be 'someikey' see defaults/main.yml"
# when:
2020-04-01 11:20:57 +13:00
- name: Ensure Duo configuration in place
ini_file:
path: /etc/duo/pam_duo.conf
section: duo
option: "{{ item.key }}"
value: "{{ item.value }}"
with_items: "{{ auth_duo_settings }}"
no_log: true
2020-04-01 11:20:57 +13:00
- name: Ensure PAM for SSH is configured with duo MFA
copy:
src: etc.pam.d.sshd
dest: /etc/pam.d/sshd
2023-10-10 23:24:47 +13:00
notify: Restart sshd
2020-04-01 11:20:57 +13:00
- name: Ensure PAM is enabled for SSH
lineinfile:
path: /etc/ssh/sshd_config
regexp: "{{ item.regex }}"
line: "{{ item.line }}"
with_items:
- regex: '^UsePAM '
line: 'UsePAM yes'
- regex: '^ChallengeResponseAuthentication '
line: 'ChallengeResponseAuthentication yes'
2023-10-10 23:24:47 +13:00
notify: Restart sshd
2020-04-01 11:20:57 +13:00
2024-12-30 08:25:21 +13:00
- name: RHEL9 - Ensure ChallengeResponseAuthentication is enabled
lineinfile:
path: /etc/ssh/sshd_config.d/50-redhat.conf
regex: '^ChallengeResponseAuthentication '
line: 'ChallengeResponseAuthentication yes'
notify: Restart sshd
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version|int >= 9
2020-04-01 11:20:57 +13:00
- name: Flush Handlers
2020-11-26 12:09:17 +13:00
meta: flush_handlers
- name: Duo SELinux Enablement
2023-10-10 23:24:47 +13:00
when: >
ansible_virtualization_type != 'docker' and
ansible_virtualization_type != 'container'
2020-11-26 12:09:17 +13:00
block:
- name: Copy SELinux Module
copy:
2020-11-26 13:28:04 +13:00
src: selinux/duo.pp
2020-11-26 12:09:17 +13:00
dest: /tmp/duo.pp
- name: Install Policy (Ensure we can access DUO Api)
command: /usr/sbin/semodule -i /tmp/duo.pp
- name: Remove Policy file
file:
path: /tmp/duo.pp
state: absent