Skip to content

Commit

Permalink
Move non-platform dependent default vars to role defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Cook committed Mar 18, 2024
1 parent cd05f45 commit 730b9e4
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 107 deletions.
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
vaultwarden_user: vaultwarden
vaultwarden_group: vaultwarden
vaultwarden_daemon: vaultwarden
vaultwarden_bin_dir: /usr/local/bin
vaultwarden_bin_file: "{{ vaultwarden_bin_dir }}/vaultwarden"
vaultwarden_home_dir: /var/lib/vaultwarden
vaultwarden_data_dir: "{{ vaultwarden_home_dir }}/data"
vaultwarden_web_vault_dir: "{{ vaultwarden_home_dir }}/web-vault"
vaultwarden_config_dir: /etc/vaultwarden
vaultwarden_config_file: "{{ vaultwarden_config_dir }}/vaultwarden.env"
vaultwarden_database_name: vaultwarden
vaultwarden_web_vault_version: 2023.10.0
vaultwarden_enable_web_vault: true
Expand Down
1 change: 0 additions & 1 deletion molecule/all/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
hosts: all

vars:
vaultwarden_file: "{{ 'molecule/vaultwarden-openssl1' if ('openssl1' in group_names) else 'molecule/vaultwarden' }}"
vaultwarden_manage_config: true

roles:
Expand Down
35 changes: 4 additions & 31 deletions molecule/all/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ platforms:
- SYS_ADMIN
cgroupns_mode: host
pre_build_image: true
- name: ubuntu2004
groups:
- openssl1
image: docker.io/geerlingguy/docker-ubuntu2004-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
cgroupns_mode: host
pre_build_image: true
- name: debian12
image: docker.io/geerlingguy/docker-debian12-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
Expand All @@ -44,10 +30,8 @@ platforms:
- SYS_ADMIN
cgroupns_mode: host
pre_build_image: true
- name: debian11
groups:
- openssl1
image: docker.io/geerlingguy/docker-debian11-ansible
- name: fedora39
image: docker.io/geerlingguy/docker-fedora39-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
Expand All @@ -70,18 +54,6 @@ platforms:
- SYS_ADMIN
cgroupns_mode: host
pre_build_image: true
- name: fedora37
image: docker.io/geerlingguy/docker-fedora37-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
cgroupns_mode: host
pre_build_image: true
- name: centosstream9
image: ghcr.io/bcook254/docker-centosstream9-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
Expand All @@ -98,7 +70,8 @@ provisioner:
name: ansible
inventory:
group_vars:
openssl1:
all:
vaultwarden_file: 'molecule/vaultwarden'
host_vars:
centosstream9:
vaultwarden_packages:
Expand Down
1 change: 0 additions & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
hosts: all

vars:
vaultwarden_file: "{{ 'molecule/vaultwarden-openssl1' if ('openssl1' in group_names) else 'molecule/vaultwarden' }}"
vaultwarden_manage_config: true

roles:
Expand Down
6 changes: 4 additions & 2 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ driver:
name: podman
platforms:
- name: ${MOLECULE_DISTRO:-ubuntu2204}
groups:
- ${MOLECULE_OPENSSL:-openssl3}
image: docker.io/geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
Expand All @@ -22,6 +20,10 @@ platforms:
pre_build_image: true
provisioner:
name: ansible
inventory:
group_vars:
all:
vaultwarden_file: 'molecule/vaultwarden'
config_options:
defaults:
interpreter_python: auto_silent
Expand Down
2 changes: 1 addition & 1 deletion tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Configure environment variables.
ansible.builtin.template:
src: "env.j2"
dest: "{{ vaultwarden_config_path }}"
dest: "{{ vaultwarden_config_file }}"
owner: "{{ vaultwarden_user }}"
group: "{{ vaultwarden_group }}"
mode: 0600
Expand Down
4 changes: 2 additions & 2 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
url: "{{ vaultwarden_url }}"
checksum: "{{ vaultwarden_url_checksum | default(omit) }}"
headers: "{{ vaultwarden_url_headers | default(omit) }}"
dest: "{{ vaultwarden_bin_dir }}/vaultwarden"
dest: "{{ vaultwarden_bin_file }}"
owner: "{{ vaultwarden_user }}"
group: "{{ vaultwarden_group }}"
mode: 0755
Expand All @@ -30,7 +30,7 @@
- name: Install Vaultwarden (Local).
ansible.builtin.copy:
src: "{{ vaultwarden_file }}"
dest: "{{ vaultwarden_bin_dir }}/vaultwarden"
dest: "{{ vaultwarden_bin_file }}"
owner: "{{ vaultwarden_user }}"
group: "{{ vaultwarden_group }}"
mode: 0755
Expand Down
36 changes: 1 addition & 35 deletions tasks/variables.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,13 @@
---
# Variable configuration.
- name: Include OS-specific variables (Debian).
ansible.builtin.include_vars: "{{ ansible_distribution }}.yml"
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
when: ansible_os_family == 'Debian'

- name: Include OS-specific variables (RedHat).
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
when:
- ansible_os_family == 'RedHat'
- ansible_distribution != 'Fedora'

- name: Include OS-specific variables (Fedora).
ansible.builtin.include_vars: "{{ ansible_distribution }}.yml"
when: ansible_distribution == 'Fedora'

- name: Define vaultwarden_bin_dir.
ansible.builtin.set_fact:
vaultwarden_bin_dir: "{{ __vaultwarden_bin_dir }}"
when: vaultwarden_bin_dir is not defined

- name: Define vaultwarden_home_dir.
ansible.builtin.set_fact:
vaultwarden_home_dir: "{{ __vaultwarden_home_dir }}"
when: vaultwarden_home_dir is not defined

- name: Define vaultwarden_data_dir.
ansible.builtin.set_fact:
vaultwarden_data_dir: "{{ __vaultwarden_data_dir }}"
when: vaultwarden_data_dir is not defined

- name: Define vaultwarden_config_dir.
ansible.builtin.set_fact:
vaultwarden_config_dir: "{{ __vaultwarden_config_dir }}"
when: vaultwarden_config_dir is not defined

- name: Define vaultwarden_config_path.
ansible.builtin.set_fact:
vaultwarden_config_path: "{{ vaultwarden_config_dir }}/vaultwarden.env"

- name: Define vaultwarden_web_vault_dir.
ansible.builtin.set_fact:
vaultwarden_web_vault_dir: "{{ __vaultwarden_web_vault_dir }}"
when: vaultwarden_web_vault_dir is not defined

- name: Define vaultwarden_packages.
ansible.builtin.set_fact:
Expand Down
5 changes: 0 additions & 5 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
---
__vaultwarden_home_dir: /var/lib/vaultwarden
__vaultwarden_data_dir: "{{ vaultwarden_home_dir }}/data"
__vaultwarden_bin_dir: /usr/local/bin
__vaultwarden_web_vault_dir: "{{ vaultwarden_home_dir }}/web-vault"
__vaultwarden_config_dir: /etc/vaultwarden
__vaultwarden_packages:
- openssl
- ca-certificates
Expand Down
12 changes: 0 additions & 12 deletions vars/Fedora.yml

This file was deleted.

5 changes: 0 additions & 5 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
---
__vaultwarden_home_dir: /var/lib/vaultwarden
__vaultwarden_data_dir: "{{ vaultwarden_home_dir }}/data"
__vaultwarden_bin_dir: /usr/local/bin
__vaultwarden_web_vault_dir: "{{ vaultwarden_home_dir }}/web-vault"
__vaultwarden_config_dir: /etc/vaultwarden
__vaultwarden_packages:
- openssl
- ca-certificates
Expand Down
12 changes: 0 additions & 12 deletions vars/Ubuntu.yml

This file was deleted.

0 comments on commit 730b9e4

Please sign in to comment.