Compare commits

...

4 Commits

Author SHA1 Message Date
uumas
6e5547a7c5 release 0.5.1 2022-01-08 01:12:17 +02:00
uumas
8904201e79 Merge branch 'master' of git.uumas.fi:uumas/ansible-general 2022-01-08 01:10:21 +02:00
uumas
4ec5ee9ad7 Made packages role compatible with other package managers 2022-01-07 22:11:17 +02:00
uumas
0e07a1e2b3 Made ssh role more configurable and less repetitive 2022-01-07 21:49:59 +02:00
6 changed files with 50 additions and 42 deletions

View File

@@ -2,7 +2,7 @@
namespace: uumas namespace: uumas
name: general name: general
version: 0.5.0 version: 0.5.1
readme: README.md readme: README.md
authors: authors:
- uumas - uumas

View File

@@ -0,0 +1,23 @@
---
- name: Ensure packages defined in install_packages are installed
apt:
name: "{{ install_packages }}"
state: present
update_cache: yes
- block:
- name: Enable backports
apt_repository:
repo: "deb http://deb.debian.org/debian {{ ansible_distribution_release }}-backports main"
filename: backports
- name: Install backports packages
apt:
name: "{{ backports_packages }}"
state: present
default_release: "{{ ansible_distribution_release }}-backports"
when: backports_packages is defined

View File

@@ -1,28 +1,15 @@
--- ---
- name: Install packages - name: Include tasks for apt as package manager
apt: include_tasks: apt.yml
name: "{{ install_packages }}" when: ansible_pkg_mgr == 'apt'
state: present
update_cache: yes
- block: - name: Include tasks for other package manager
include_tasks: other.yml
when: ansible_pkg_mgr != 'apt'
- name: Enable backports - name: Ensure packages defined in delete_packages not installed
apt_repository: package:
repo: "deb http://deb.debian.org/debian {{ ansible_distribution_release }}-backports main"
filename: backports
- name: Install backports packages
apt:
name: "{{ backports_packages }}"
state: present
default_release: "{{ ansible_distribution_release }}-backports"
when: backports_packages is defined
- name: Delete packages
apt:
name: "{{ delete_packages }}" name: "{{ delete_packages }}"
state: absent state: absent
when: delete_packages is defined when: delete_packages is defined

View File

@@ -0,0 +1,7 @@
---
- name: Ensure packages defined in install_packages are installed
package:
name: "{{ install_packages }}"
state: present

View File

@@ -0,0 +1,4 @@
---
sshd_x11_forwarding: false
sshd_password_auth: false

View File

@@ -1,28 +1,15 @@
--- ---
- name: Disable SSH root login without password - name: Ensure sshd config options set correctly
lineinfile: lineinfile:
path: /etc/ssh/sshd_config path: /etc/ssh/sshd_config
regexp: '^#?PermitRootLogin .*$' regexp: "^#?{{ item.key }} .*$"
line: "PermitRootLogin prohibit-password" line: "{{ item.key }} {{ item.value }}"
state: present state: present
validate: '/usr/sbin/sshd -t -f %s' validate: '/usr/sbin/sshd -t -f %s'
notify: restart ssh notify: restart ssh
with_dict:
PermitRootLogin: 'prohibit-password'
PasswordAuthentication: "{{ 'yes' if sshd_password_auth else 'no' }}"
X11Forwarding: "{{ 'yes' if sshd_x11_forwarding else 'no' }}"
- name: Disable PasswordAuthentication
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#PasswordAuthentication .*$'
line: "PasswordAuthentication no"
state: present
validate: '/usr/sbin/sshd -t -f %s'
notify: restart ssh
- name: Disable X11 forwarding
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?X11Forwarding .*$'
line: "X11Forwarding no"
state: present
validate: '/usr/sbin/sshd -t -f %s'
notify: restart ssh