Compare commits

...

6 Commits

Author SHA1 Message Date
uumas
88318942e9 Rename galaxy.yaml and meta/runtime.yaml back to .yml
due to ansible-galaxy requirement
2025-01-27 05:25:56 +02:00
uumas
8988b8a1b5 v0.5.14 2025-01-27 04:58:16 +02:00
uumas
b76fce1e1f lint: .yml -> .yaml 2025-01-27 04:57:37 +02:00
uumas
e2f5e49fe8 ssh: use sshd instead of ssh to make it work on fedora 2025-01-27 04:55:32 +02:00
uumas
d94cc30aa5 compatcheck: Support checking for package manager
Some distros (fedora) have dnf by default but may be atomic also
2025-01-27 04:54:29 +02:00
uumas
34de2fe02b lint: remove empty lines after --- 2025-01-27 04:53:33 +02:00
29 changed files with 40 additions and 41 deletions

View File

@@ -1,5 +1,4 @@
---
Creates users specified in the `users` variable. Syntax:
```

View File

@@ -1,9 +1,8 @@
---
namespace: uumas
name: general
description: General roles
version: 0.5.13
version: 0.5.14
readme: README.md
authors:
- uumas

View File

@@ -1,3 +1,2 @@
---
requires_ansible: ">=2.10"
requires_ansible: ">=2.17.0"

View File

@@ -1,5 +1,4 @@
---
argument_specs:
main:
short_description: Apt repository

View File

@@ -1,5 +1,4 @@
---
- name: Install dependencies
ansible.builtin.apt:
name:

View File

@@ -1,5 +1,4 @@
---
- name: Reload caddy
ansible.builtin.systemd:
name: caddy

View File

@@ -30,3 +30,13 @@ argument_specs:
description: Last supported major version. Allows any version if not specified.
type: int
required: false
package_managers:
description: List of supported package managers. Defaults to apt for debian and ubuntu, dnf for fedora, pacman for archlinux
type: list
required: false
elements: str
choices:
- apt
- dnf
- pacman
- atomic_container

View File

@@ -2,14 +2,12 @@
- name: Fail if distribution not supported
ansible.builtin.fail:
msg: "{{ lookup('ansible.builtin.template', 'distroerror.j2').strip() }}"
when: checkfailed
loop:
- "{{ compatcheck_distro | length == 0 }}"
- >
{{
when: >
_compatcheck_distro | length != 1 or (
ansible_distribution_major_version != 'n/a' and
compatcheck_distro[0].version_min | default(0) > ansible_distribution_major_version | int
}}
- "{{ compatcheck_distro[0].version_max is defined and compatcheck_distro[0].version_max < ansible_distribution_major_version | int }}"
_compatcheck_distro[0].version_min | default(0) > ansible_distribution_major_version | int
) or
_compatcheck_distro[0].version_max is defined and _compatcheck_distro[0].version_max < ansible_distribution_major_version | int or
ansible_pkg_mgr not in _compatcheck_distro[0].package_managers | default([_compatcheck_default_package_manager])
loop_control:
loop_var: checkfailed

View File

@@ -1,15 +1,18 @@
{%- set distros = [] -%}
{%- for distro in compatcheck_supported_distributions -%}
{% set distro_package_managers = distro.package_managers | default([_compatcheck_default_package_managers[distro.name]]) %}
{% set distro_package_managers_str = ' (' ~ ', '.join(distro_package_managers) ~ ')' %}
{% set distro_name = distro.name | capitalize %}
{%- if distro.version_min is defined -%}
{%- if distro.version_max is defined -%}
{{ distros.append(distro.name | capitalize + ' ' + distro.version_min | string + '-' + distro.version_max | string) }}
{{ distros.append(distro_name ~ ' ' ~ distro.version_min ~ '-' ~ distro.version_max ~ distro_package_managers_str) }}
{%- else -%}
{{ distros.append(distro.name | capitalize + ' ' + distro.version_min | string + '+') }}
{{ distros.append(distro_name ~ ' ' ~ distro.version_min ~ '+' ~ distro_package_managers_str) }}
{%- endif -%}
{%- elif distro.version_max is defined -%}
{{ distros.append(distro.name | capitalize + ' <' + distro.version_max | string) }}
{{ distros.append(distro_name ~ ' <' ~ distro.version_max ~ distro_package_managers_str) }}
{%- else -%}
{{ distros.append(distro.name | capitalize) }}
{{ distros.append(distro_name ~ distro_package_managers_str) }}
{%- endif -%}
{%- endfor -%}
This role only supports {{ distros | join(', ') }} (You are running {{ ansible_distribution }} {{ ansible_distribution_major_version }})
This role only supports {{ distros | join(', ') }} (You are running {{ ansible_distribution }} {{ ansible_distribution_major_version }} ({{ ansible_pkg_mgr }})

View File

@@ -1,2 +1,8 @@
---
compatcheck_distro: "{{ compatcheck_supported_distributions | selectattr('name', 'equalto', ansible_distribution | lower) }}"
_compatcheck_distro: "{{ compatcheck_supported_distributions | selectattr('name', 'equalto', ansible_distribution | lower) }}"
_compatcheck_default_package_managers:
debian: apt
ubuntu: apt
fedora: dnf
archlinux: pacman
_compatcheck_default_package_manager: "{{ _compatcheck_default_package_managers[ansible_distribution | lower] }}"

View File

@@ -1,5 +1,4 @@
---
install_packages:
- sudo
- vim

View File

@@ -1,5 +1,4 @@
---
- name: Ensure packages defined in install_packages are installed
ansible.builtin.apt:
name: "{{ install_packages }}"

View File

@@ -1,5 +1,4 @@
---
- name: Include tasks for apt as package manager
ansible.builtin.include_tasks: apt.yml
when: ansible_pkg_mgr == 'apt'

View File

@@ -1,5 +1,4 @@
---
- name: Ensure packages defined in install_packages are installed
ansible.builtin.package:
name: "{{ install_packages }}"

View File

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

View File

@@ -0,0 +1,5 @@
---
- name: Restart sshd
ansible.builtin.systemd_service:
name: sshd.service
state: restarted

View File

@@ -1,6 +0,0 @@
---
- name: Restart ssh
ansible.builtin.systemd:
name: ssh
state: restarted

View File

@@ -1,5 +1,4 @@
---
- name: Ensure sshd config options set correctly
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
@@ -7,7 +6,7 @@
line: "{{ item.key }} {{ item.value }}"
state: present
validate: '/usr/sbin/sshd -t -f %s'
notify: Restart ssh
notify: Restart sshd
with_dict:
PermitRootLogin: 'prohibit-password'
PasswordAuthentication: "{{ 'yes' if sshd_password_auth else 'no' }}"

View File

@@ -1,5 +1,4 @@
---
- name: Ensure sudo is installed
ansible.builtin.package:
name: sudo

View File

@@ -1,5 +1,4 @@
---
vhost_state: present
vhost_type: "{{ vhost_state }}"
vhost_domains: []

View File

@@ -1,5 +1,4 @@
---
dependencies:
- role: caddy
when: vhost_web_server == 'caddy'

View File

@@ -1,5 +1,4 @@
---
- name: Add caddy vhost config
ansible.builtin.blockinfile:
path: /etc/caddy/Caddyfile

View File

@@ -1,5 +1,4 @@
---
- name: Fail if vhost_redirect_target is a relative path and vhost_redirect_preserve_path is true
ansible.builtin.fail:
msg: vhost_redirect_target must be an absolute url or absolute path if vhost_redirect_preserve_path is true