diff options
| author | Kumar Damani <me@kumardamani.net> | 2025-06-30 21:11:10 +0000 |
|---|---|---|
| committer | Kumar Damani <me@kumardamani.net> | 2025-06-30 21:11:10 +0000 |
| commit | a125ec65a120ce23e4e692a48eaa169bc40e5506 (patch) | |
| tree | c1c7ed19c1e00f33d5fe6d7caa3c622945b3c423 /ansible/roles | |
| parent | 7e603bcc92c7ddc19dbfb0c46434bc6847ad3781 (diff) | |
ansible refactor to newer methods
Diffstat (limited to 'ansible/roles')
33 files changed, 257 insertions, 95 deletions
diff --git a/ansible/roles/caddy_add/meta/argument_specs.yaml b/ansible/roles/caddy_add/meta/argument_specs.yaml new file mode 100644 index 0000000..3c40bd6 --- /dev/null +++ b/ansible/roles/caddy_add/meta/argument_specs.yaml @@ -0,0 +1,26 @@ +--- + +argument_specs: + main: + short_description: Main entry point for the Caddy add role + description: + - This role updates our Caddy RProxy via it's API with a new route. + author: + - Kumar Damani + options: + caddy_add_hosts: + type: 'list' + elements: 'str' + required: true + description: + - The desired fqdn for the service to add. + caddy_add_upstream_host: + type: 'str' + required: true + description: + - The hostname of the host hosting this service. + caddy_add_upstream_port: + type: 'int' + required: true + description: + - The port of the service on the host. diff --git a/ansible/roles/caddy_add/meta/main.yaml b/ansible/roles/caddy_add/meta/main.yaml new file mode 100644 index 0000000..0f50759 --- /dev/null +++ b/ansible/roles/caddy_add/meta/main.yaml @@ -0,0 +1,3 @@ +--- + +dependencies: [] diff --git a/ansible/roles/caddy_add/tasks/main.yaml b/ansible/roles/caddy_add/tasks/main.yaml index 4dcbd8a..8177f6a 100644 --- a/ansible/roles/caddy_add/tasks/main.yaml +++ b/ansible/roles/caddy_add/tasks/main.yaml @@ -1,14 +1,5 @@ --- -- name: 'Ensure required vars are set' - ansible.builtin.assert: - that: - - item | mandatory - loop: - - '{{ caddy_add_hosts }}' - - '{{ caddy_add_upstream_host }}' - - '{{ caddy_add_upstream_port }}' - - name: 'Call the Caddy API to add our new host' ansible.builtin.uri: url: 'http://rproxy:2019/config/apps/http/servers/srv0/routes/0' diff --git a/ansible/roles/med_dl/defaults/main.yaml b/ansible/roles/med_dl/defaults/main.yaml new file mode 100644 index 0000000..4e58323 --- /dev/null +++ b/ansible/roles/med_dl/defaults/main.yaml @@ -0,0 +1,3 @@ +--- + +med_dl_nas_mount_path: '{{ vaultvar_med_dl_nas_nfs_path }}' diff --git a/ansible/roles/med_dl/meta/argument_specs.yaml b/ansible/roles/med_dl/meta/argument_specs.yaml new file mode 100644 index 0000000..6718b94 --- /dev/null +++ b/ansible/roles/med_dl/meta/argument_specs.yaml @@ -0,0 +1,16 @@ +--- + +argument_specs: + main: + short_description: Main entry point for the Media Downloader role + description: + - This role installs the *arr apps as a Docker Compose project. + - We install Prowlarr, Sonarr, Radarr, Lidarr. + author: + - Kumar Damani + options: + med_dl_nas_mount_path: + type: 'str' + required: true + description: + - The path to the data on the NFS share. diff --git a/ansible/roles/med_dl/meta/main.yaml b/ansible/roles/med_dl/meta/main.yaml new file mode 100644 index 0000000..bd4979e --- /dev/null +++ b/ansible/roles/med_dl/meta/main.yaml @@ -0,0 +1,5 @@ +--- + +dependencies: + - role: 'base' + - role: 'docker' diff --git a/ansible/roles/med_dl/tasks/config.yaml b/ansible/roles/med_dl/tasks/config.yaml new file mode 100644 index 0000000..367e7d5 --- /dev/null +++ b/ansible/roles/med_dl/tasks/config.yaml @@ -0,0 +1,12 @@ +--- + +- name: 'config | Copy the docker-compose file' + ansible.builtin.template: + src: 'docker-compose.yaml.j2' + dest: 'docker-compose.yaml' + mode: '644' + +- name: 'config | Start the service' + ansible.builtin.command: 'docker-compose up -d' + register: '_compose_up_cmd' + changed_when: '_compose_up_cmd.rc == 0' diff --git a/ansible/roles/med_dl/tasks/main.yaml b/ansible/roles/med_dl/tasks/main.yaml index 8c28b2b..62d9b46 100644 --- a/ansible/roles/med_dl/tasks/main.yaml +++ b/ansible/roles/med_dl/tasks/main.yaml @@ -2,3 +2,8 @@ - name: 'Run the setup tasks' ansible.builtin.import_tasks: 'setup.yaml' + tags: ['install'] + +- name: 'Run the config tasks' + ansible.builtin.import_tasks: 'config.yaml' + tags: ['install', 'config'] diff --git a/ansible/roles/med_dl/tasks/setup.yaml b/ansible/roles/med_dl/tasks/setup.yaml index b1a1873..c3053e8 100644 --- a/ansible/roles/med_dl/tasks/setup.yaml +++ b/ansible/roles/med_dl/tasks/setup.yaml @@ -1,13 +1,5 @@ --- -- name: 'setup | Ensure required vars are set' - ansible.builtin.assert: - that: - - item | mandatory - loop: - - '{{ med_dl_nas_mount_path }}' - no_log: true - - name: 'setup | Install required pkgs' ansible.builtin.package: name: @@ -25,14 +17,3 @@ path: '/mnt/data' state: 'mounted' fstype: 'nfs' - -- name: 'setup | Copy the docker-compose file' - ansible.builtin.template: - src: 'docker-compose.yaml.j2' - dest: 'docker-compose.yaml' - mode: '644' - -- name: 'setup | Start the service' - ansible.builtin.command: 'docker-compose up -d' - register: '_compose_up_cmd' - changed_when: '_compose_up_cmd.rc == 0' diff --git a/ansible/roles/monitoring/meta/argument_specs.yaml b/ansible/roles/monitoring/meta/argument_specs.yaml new file mode 100644 index 0000000..54b59c3 --- /dev/null +++ b/ansible/roles/monitoring/meta/argument_specs.yaml @@ -0,0 +1,10 @@ +--- + +argument_specs: + main: + short_description: Main entry point for the monitoring role + description: + - This role installs the Prometheus + Grafana as systemd services. + author: + - Kumar Damani + options: {} diff --git a/ansible/roles/monitoring/meta/main.yaml b/ansible/roles/monitoring/meta/main.yaml new file mode 100644 index 0000000..93c21f6 --- /dev/null +++ b/ansible/roles/monitoring/meta/main.yaml @@ -0,0 +1,4 @@ +--- + +dependencies: + - role: 'base' diff --git a/ansible/roles/monitoring/tasks/config.yaml b/ansible/roles/monitoring/tasks/config.yaml new file mode 100644 index 0000000..20e64db --- /dev/null +++ b/ansible/roles/monitoring/tasks/config.yaml @@ -0,0 +1,13 @@ +--- + +- name: 'config | Set the Prom config' + ansible.builtin.template: + src: 'prometheus.yml.j2' + dest: '/etc/prometheus/prometheus.yml' + mode: '644' + +- name: 'config | Start the service' + ansible.builtin.service: + name: 'prometheus' + state: 'restarted' + enabled: true diff --git a/ansible/roles/monitoring/tasks/main.yaml b/ansible/roles/monitoring/tasks/main.yaml index 256a09f..62d9b46 100644 --- a/ansible/roles/monitoring/tasks/main.yaml +++ b/ansible/roles/monitoring/tasks/main.yaml @@ -2,4 +2,8 @@ - name: 'Run the setup tasks' ansible.builtin.import_tasks: 'setup.yaml' - tags: 'monitoring' + tags: ['install'] + +- name: 'Run the config tasks' + ansible.builtin.import_tasks: 'config.yaml' + tags: ['install', 'config'] diff --git a/ansible/roles/monitoring/tasks/setup.yaml b/ansible/roles/monitoring/tasks/setup.yaml index 824d2db..63ab962 100644 --- a/ansible/roles/monitoring/tasks/setup.yaml +++ b/ansible/roles/monitoring/tasks/setup.yaml @@ -6,15 +6,3 @@ - 'prometheus' - 'prometheus-node-exporter' - 'prometheus-blackbox-exporter' - -- name: 'setup | Set the Prom config' - ansible.builtin.template: - src: 'prometheus.yml.j2' - dest: '/etc/prometheus/prometheus.yml' - mode: '644' - -- name: 'setup | Start the service' - ansible.builtin.service: - name: 'prometheus' - state: 'restarted' - enabled: true diff --git a/ansible/roles/nextcloud/defaults/main.yaml b/ansible/roles/nextcloud/defaults/main.yaml new file mode 100644 index 0000000..138231f --- /dev/null +++ b/ansible/roles/nextcloud/defaults/main.yaml @@ -0,0 +1,10 @@ +--- + +nextcloud_nas_mount_path: '{{ vaultvar_nextcloud_nas_nfs_path }}' +nextcloud_php_max_mem_mb: 8000 +nextcloud_php_max_upload_size_gb: 10 +# You should have DRI devices showing up in your container in `/dev/dri/`. +# See the TF readme for steps to enable this. +# If not, then set this to false here. +# Leave this as a yaml string, it is going to used as a shell var. +nextcloud_enable_dri: 'true' diff --git a/ansible/roles/nextcloud/meta/argument_specs.yaml b/ansible/roles/nextcloud/meta/argument_specs.yaml new file mode 100644 index 0000000..60a7f85 --- /dev/null +++ b/ansible/roles/nextcloud/meta/argument_specs.yaml @@ -0,0 +1,25 @@ +--- + +argument_specs: + main: + short_description: Main entry point for the Nextcloud AIO role + description: + - This role installs the Nextcloud All-in-One flavour as a Docker Compose project. + author: + - Kumar Damani + options: + nextcloud_nas_mount_path: + type: 'str' + required: true + description: + - The path to the data on the NFS share. + nextcloud_php_max_mem_mb: + type: 'int' + required: true + description: + - The max mem in MB to give PHP. + nextcloud_php_max_upload_size_gb: + type: 'int' + required: true + description: + - The max size in GB to allow for file uploads. diff --git a/ansible/roles/nextcloud/meta/main.yaml b/ansible/roles/nextcloud/meta/main.yaml new file mode 100644 index 0000000..bd4979e --- /dev/null +++ b/ansible/roles/nextcloud/meta/main.yaml @@ -0,0 +1,5 @@ +--- + +dependencies: + - role: 'base' + - role: 'docker' diff --git a/ansible/roles/nextcloud/tasks/config.yaml b/ansible/roles/nextcloud/tasks/config.yaml new file mode 100644 index 0000000..367e7d5 --- /dev/null +++ b/ansible/roles/nextcloud/tasks/config.yaml @@ -0,0 +1,12 @@ +--- + +- name: 'config | Copy the docker-compose file' + ansible.builtin.template: + src: 'docker-compose.yaml.j2' + dest: 'docker-compose.yaml' + mode: '644' + +- name: 'config | Start the service' + ansible.builtin.command: 'docker-compose up -d' + register: '_compose_up_cmd' + changed_when: '_compose_up_cmd.rc == 0' diff --git a/ansible/roles/nextcloud/tasks/main.yaml b/ansible/roles/nextcloud/tasks/main.yaml index 0d3697b..62d9b46 100644 --- a/ansible/roles/nextcloud/tasks/main.yaml +++ b/ansible/roles/nextcloud/tasks/main.yaml @@ -2,4 +2,8 @@ - name: 'Run the setup tasks' ansible.builtin.import_tasks: 'setup.yaml' - tags: 'nextcloud' + tags: ['install'] + +- name: 'Run the config tasks' + ansible.builtin.import_tasks: 'config.yaml' + tags: ['install', 'config'] diff --git a/ansible/roles/nextcloud/tasks/setup.yaml b/ansible/roles/nextcloud/tasks/setup.yaml index ac17702..ae3bff9 100644 --- a/ansible/roles/nextcloud/tasks/setup.yaml +++ b/ansible/roles/nextcloud/tasks/setup.yaml @@ -1,15 +1,5 @@ --- -- name: 'setup | Ensure required vars are set' - ansible.builtin.assert: - that: - - item | mandatory - loop: - - '{{ nextcloud_nas_mount_path }}' - - '{{ nextcloud_php_max_mem_mb }}' - - '{{ nextcloud_php_max_upload_size_gb }}' - no_log: true - - name: 'setup | Install required pkgs' ansible.builtin.package: name: @@ -27,14 +17,3 @@ path: '/mnt/data' state: 'mounted' fstype: 'nfs' - -- name: 'setup | Copy the docker-compose file' - ansible.builtin.template: - src: 'docker-compose.yaml.j2' - dest: 'docker-compose.yaml' - mode: '644' - -- name: 'setup | Start the service' - ansible.builtin.command: 'docker-compose up -d' - register: '_compose_up_cmd' - changed_when: '_compose_up_cmd.rc == 0' diff --git a/ansible/roles/plex/defaults/main.yaml b/ansible/roles/plex/defaults/main.yaml new file mode 100644 index 0000000..94c410b --- /dev/null +++ b/ansible/roles/plex/defaults/main.yaml @@ -0,0 +1,3 @@ +--- + +plex_nas_mount_path: '{{ vaultvar_torrents_nas_nfs_path }}' diff --git a/ansible/roles/plex/meta/argument_specs.yaml b/ansible/roles/plex/meta/argument_specs.yaml new file mode 100644 index 0000000..7c49c67 --- /dev/null +++ b/ansible/roles/plex/meta/argument_specs.yaml @@ -0,0 +1,15 @@ +--- + +argument_specs: + main: + short_description: Main entry point for the Plex role + description: + - This role installs the Plex Media Server as a systemd service. + author: + - Kumar Damani + options: + plex_nas_mount_path: + type: 'str' + required: true + description: + - The path to the data on the NFS share. diff --git a/ansible/roles/plex/meta/main.yaml b/ansible/roles/plex/meta/main.yaml new file mode 100644 index 0000000..93c21f6 --- /dev/null +++ b/ansible/roles/plex/meta/main.yaml @@ -0,0 +1,4 @@ +--- + +dependencies: + - role: 'base' diff --git a/ansible/roles/plex/tasks/main.yaml b/ansible/roles/plex/tasks/main.yaml index 5469534..506eb4c 100644 --- a/ansible/roles/plex/tasks/main.yaml +++ b/ansible/roles/plex/tasks/main.yaml @@ -2,4 +2,4 @@ - name: 'Run the setup tasks' ansible.builtin.import_tasks: 'setup.yaml' - tags: 'plex' + tags: ['install'] diff --git a/ansible/roles/torrents/defaults/main.yaml b/ansible/roles/torrents/defaults/main.yaml new file mode 100644 index 0000000..45c9780 --- /dev/null +++ b/ansible/roles/torrents/defaults/main.yaml @@ -0,0 +1,5 @@ +--- + +torrents_nas_mount_path: '{{ vaultvar_torrents_nas_nfs_path }}' +torrents_rpc_username: '{{ vaultvar_torrents_rpc_username }}' +torrents_rpc_password: '{{ vaultvar_torrents_rpc_password }}' diff --git a/ansible/roles/torrents/meta/argument_specs.yaml b/ansible/roles/torrents/meta/argument_specs.yaml new file mode 100644 index 0000000..21691c7 --- /dev/null +++ b/ansible/roles/torrents/meta/argument_specs.yaml @@ -0,0 +1,25 @@ +--- + +argument_specs: + main: + short_description: Main entry point for the torrents role + description: + - This role installs the Transmission server as a systemd service. + author: + - Kumar Damani + options: + torrents_nas_mount_path: + type: 'str' + required: true + description: + - The path to the data on the NFS share. + torrents_rpc_username: + type: 'str' + required: true + description: + - The username. + torrents_rpc_password: + type: 'str' + required: true + description: + - The psswd for the user. diff --git a/ansible/roles/torrents/meta/main.yaml b/ansible/roles/torrents/meta/main.yaml new file mode 100644 index 0000000..93c21f6 --- /dev/null +++ b/ansible/roles/torrents/meta/main.yaml @@ -0,0 +1,4 @@ +--- + +dependencies: + - role: 'base' diff --git a/ansible/roles/torrents/tasks/config.yaml b/ansible/roles/torrents/tasks/config.yaml new file mode 100644 index 0000000..d375645 --- /dev/null +++ b/ansible/roles/torrents/tasks/config.yaml @@ -0,0 +1,20 @@ +--- + +# We still need to stop it to place the config file or else it will get overwritten +- name: 'config | Stop the service' + ansible.builtin.service: + name: 'transmission-daemon' + state: 'stopped' + +- name: 'config | Copy the transmission config' + ansible.builtin.template: + src: 'settings.json.j2' + dest: '/home/transmission-user/.config/transmission-daemon/settings.json' + owner: 'transmission-user' + mode: '644' + +- name: 'config | Start the service' + ansible.builtin.service: + name: 'transmission-daemon' + state: 'started' + enabled: true diff --git a/ansible/roles/torrents/tasks/main.yaml b/ansible/roles/torrents/tasks/main.yaml index 806a4e3..62d9b46 100644 --- a/ansible/roles/torrents/tasks/main.yaml +++ b/ansible/roles/torrents/tasks/main.yaml @@ -2,4 +2,8 @@ - name: 'Run the setup tasks' ansible.builtin.import_tasks: 'setup.yaml' - tags: 'torrents' + tags: ['install'] + +- name: 'Run the config tasks' + ansible.builtin.import_tasks: 'config.yaml' + tags: ['install', 'config'] diff --git a/ansible/roles/torrents/tasks/setup.yaml b/ansible/roles/torrents/tasks/setup.yaml index 25f1fe8..1aaaa83 100644 --- a/ansible/roles/torrents/tasks/setup.yaml +++ b/ansible/roles/torrents/tasks/setup.yaml @@ -1,15 +1,5 @@ --- -- name: 'setup | Ensure required vars are set' - ansible.builtin.assert: - that: - - item | mandatory - loop: - - '{{ torrents_nas_mount_path }}' - - '{{ torrents_rpc_username }}' - - '{{ torrents_rpc_password }}' - no_log: true - - name: 'setup | Install required pkgs' ansible.builtin.package: name: @@ -58,22 +48,3 @@ ansible.builtin.service: name: 'transmission-daemon' state: 'started' - -# We still need to stop it to place the config file or else it will get overwritten -- name: 'setup | Stop the service' - ansible.builtin.service: - name: 'transmission-daemon' - state: 'stopped' - -- name: 'setup | Copy the transmission config' - ansible.builtin.template: - src: 'settings.json.j2' - dest: '/home/transmission-user/.config/transmission-daemon/settings.json' - owner: 'transmission-user' - mode: '644' - -- name: 'setup | Start the service' - ansible.builtin.service: - name: 'transmission-daemon' - state: 'started' - enabled: true diff --git a/ansible/roles/vault/meta/argument_specs.yaml b/ansible/roles/vault/meta/argument_specs.yaml new file mode 100644 index 0000000..9e8ccd6 --- /dev/null +++ b/ansible/roles/vault/meta/argument_specs.yaml @@ -0,0 +1,10 @@ +--- + +argument_specs: + main: + short_description: Main entry point for the vault role + description: + - This role installs Vaultwarden (a FOSS fork of Bitwarden) as a Docker Compose project. + author: + - Kumar Damani + options: {} diff --git a/ansible/roles/vault/meta/main.yaml b/ansible/roles/vault/meta/main.yaml new file mode 100644 index 0000000..bd4979e --- /dev/null +++ b/ansible/roles/vault/meta/main.yaml @@ -0,0 +1,5 @@ +--- + +dependencies: + - role: 'base' + - role: 'docker' diff --git a/ansible/roles/vault/tasks/main.yaml b/ansible/roles/vault/tasks/main.yaml index 191bbc1..506eb4c 100644 --- a/ansible/roles/vault/tasks/main.yaml +++ b/ansible/roles/vault/tasks/main.yaml @@ -2,4 +2,4 @@ - name: 'Run the setup tasks' ansible.builtin.import_tasks: 'setup.yaml' - tags: 'vault' + tags: ['install'] |
