Skip to content
Snippets Groups Projects
Commit 33f6d695 authored by nimrod's avatar nimrod
Browse files

- Use assertions in tasks files.

- Use Ansible module to check the dhparams file.
- Updated TODO list.
parent 2b3232f2
No related branches found
No related tags found
No related merge requests found
...@@ -73,8 +73,19 @@ at: https://www.shore.co.il/cgit/. ...@@ -73,8 +73,19 @@ at: https://www.shore.co.il/cgit/.
TODO TODO
---- ----
- Implement add_repo, add_tls_cert, debian_backports, collectd_agent, init (with - Implement:
Ansible module), ldap_login, mail_forwarding, ntp, ssh_ca, syslog_forwarding. - add_tls_cert (Debian works, OpenBSD has no mechannism).
- debian_backports (add Ubuntu, priority support).
- collectd_agent.
- init.
- ldap_login (with pam_mkhomedir).
- ntp.
- mail_forward (OpenBSD support?).
- ssh_ca.
- syslog_forwarding.
- Update `tasks/main.yml` to reflect recent assert changes.
- Test. - Test.
- Document. - Document.
- ldap-login should also enable mkhomedir. - Create a module to add a TLS certificate to store for both Debian-based and
OpenBSD.
- Create a module to detect the init system.
---
- name: Assert
assert:
that:
- "ansible_pkg_mgr == 'apt'"
- "extra_repos is defined"
- name: Add additional apt repository keys
with_items: extra_repos
when: item.key_url is defined or item.key_data is defined
apt_key:
url: '{{ item.key_url|default(omit) }}'
data: '{{ item.key_data|default(omit) }}'
state: present
- name: Add additional apt repository
with_items: extra_repos
apt_repository:
repo: '{{ item.repo }}'
state: present
update_cache: yes
--- ---
- name: Assert
assert:
that:
- "ansible_os_family in [ 'Debian' ]"
- "extra_tls_certs is defined"
- name: apt install CA certificates - name: apt install CA certificates
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
apt: apt:
......
--- ---
- name: Assert
assert:
that: ansible_distribution == 'Debian'
- name: Add backports repositories - name: Add backports repositories
with_items: with_items:
- deb - deb
...@@ -12,9 +17,7 @@ ...@@ -12,9 +17,7 @@
when: backports_priority is defined when: backports_priority is defined
template: template:
src: backports.j2 src: backports.j2
dest: //etc/apt/preferences.d/backports dest: /etc/apt/preferences.d/backports
owner: root owner: root
group: root group: root
mode: '0644' mode: '0644'
# TODO: Add support for Ubuntu, gather enabled archives (non-free, multiverse).
--- ---
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
- name: apt install Collectd - name: apt install Collectd
when: ansible_pkg_mgr == 'apt' when: ansible_pkg_mgr == 'apt'
apt: apt:
......
--- ---
- name: Assert
assert:
that: ansible_os_family == 'Debian'
- name: Find which package provided init - name: Find which package provided init
command: /usr/bin/dpkg -S /sbin/init command: /usr/bin/dpkg -S /sbin/init
register: common_which_init register: common_which_init
......
---
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
--- ---
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
- name: apt install exim - name: apt install exim
when: ansible_pkg_mgr == 'apt'
apt: apt:
name: exim4 name: exim4
state: present state: present
......
--- ---
# tasks file for ansible_common # tasks file for ansible_common
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
- include: init.yml - include: init.yml
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- include: backports.yml - include: backports.yml
when: backports|default(False) and ansible_distribution == 'Debian' when: backports|default(False) and ansible_distribution == 'Debian'
- include: add_repo.yml repo='{{ item }}' - include: add_repo.yml
when: ansible_distribution == 'Debian' when: ansible_distribution == 'Debian' and extra_repos is defined
- include: ufw.yml - include: ufw.yml
when: ufw|default(True) and ansible_os_family == 'Debian' when: ufw|default(True) and ansible_os_family == 'Debian'
......
---
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
---
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
--- ---
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
- name: Add sudo group - name: Add sudo group
group: group:
name: sudo name: sudo
......
--- ---
- name: Assert
assert:
that: ansible_os_family in [ 'Debian', 'OpenBSD' ]
- name: apt install rsyslog - name: apt install rsyslog
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
apt: apt:
......
---
- name: Assert
assert:
that: ansible_os_family in [ 'Debian' ]
- name: apt install TLS CA certs - name: apt install TLS CA certs
apt: apt:
name: '{{ item }}' name: '{{ item }}'
...@@ -42,10 +48,11 @@ ...@@ -42,10 +48,11 @@
when: tls_copy.changed when: tls_copy.changed
- name: Check if dhparams exists and its length - name: Check if dhparams exists and its length
changed_when: False ignore_errors: yes
script: dhparams.sh dhparams:
register: dhparams path: /etc/ssl/dhparams.pem
register: tls_dhparams
- name: Generate dhparams - name: Generate dhparams (this will take a while)
when: dhparams.stdout|int < 2048 when: tls_dhparams.bits < 2048
command: /usr/bin/openssl dhparam -out /etc/ssl/dhparams.pem 2048 command: /usr/bin/openssl dhparam -out /etc/ssl/dhparams.pem 2048
--- ---
- name: Assert
assert:
that: ansible_pkg_mgr == 'apt'
- name: apt install ufw - name: apt install ufw
apt: apt:
name: ufw name: ufw
......
--- ---
- name: Assert
assert:
that: ansible_pkg_mgr == 'apt'
- name: apt install unattended-upgrades - name: apt install unattended-upgrades
apt: apt:
name: unattended-upgrades name: unattended-upgrades
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment