85 lines
3.1 KiB
YAML
85 lines
3.1 KiB
YAML
- name: Install Archer A9 Router Rebooter
|
|
hosts: Rivendell
|
|
vars_prompt:
|
|
- name: router_password
|
|
prompt: Enter password for Archer A9 router
|
|
tasks:
|
|
- name: Create Archer A9 Router Rebooter logs Docker volume directory
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: /data/archer-a9-router-rebooter-logs
|
|
state: directory
|
|
- name: Create Archer A9 Router Rebooter logs Docker volume
|
|
community.docker.docker_volume:
|
|
volume_name: archer-a9-router-rebooter-logs
|
|
driver: local
|
|
driver_options:
|
|
type: none
|
|
o: bind
|
|
device: /data/archer-a9-router-rebooter-logs
|
|
state: present
|
|
|
|
- name: Create temporary Docker build directory
|
|
ansible.builtin.tempfile:
|
|
state: directory
|
|
register: docker_build_dir
|
|
- name: Copy Docker build directory
|
|
ansible.builtin.copy:
|
|
src: rebooter/
|
|
dest: '{{docker_build_dir.path}}'
|
|
mode: preserve
|
|
- name: Build archer-a9-router-rebooter Docker image
|
|
community.docker.docker_image:
|
|
build:
|
|
path: '{{docker_build_dir.path}}'
|
|
name: archer-a9-router-rebooter
|
|
tag: latest
|
|
source: build
|
|
force_source: true
|
|
state: present
|
|
- name: Remove temporary Docker build directory
|
|
ansible.builtin.file:
|
|
path: '{{docker_build_dir.path}}'
|
|
state: absent
|
|
|
|
- name: Read homelab config
|
|
ansible.builtin.slurp:
|
|
src: '{{ansible_user_dir}}/.homelab.json'
|
|
register: homelab_config_file
|
|
- name: Set homelab_config variable
|
|
ansible.builtin.set_fact:
|
|
homelab_config: '{{homelab_config_file.content|b64decode|from_json}}'
|
|
|
|
- name: Insert into Postgres table service
|
|
vars:
|
|
archer_a9_router_rebooter_config:
|
|
router:
|
|
password: '{{router_password}}'
|
|
community.postgresql.postgresql_query:
|
|
login_host: '{{homelab_config.database.host}}'
|
|
login_user: '{{homelab_config.database.user}}'
|
|
login_password: '{{homelab_config.database.password}}'
|
|
db: '{{homelab_config.database.name}}'
|
|
query: 'INSERT INTO service (name, host, source, config) VALUES (%s, %s, %s, %s) ON CONFLICT DO NOTHING;'
|
|
positional_args:
|
|
- '{{item.name}}'
|
|
- '{{item.host}}'
|
|
- '{{item.source}}'
|
|
- '{{item.config}}'
|
|
with_items:
|
|
- {name: archer_a9_router_rebooter, host: '{{ansible_hostname}}', source: gitea/ashish/archer-a9-router-rebooter/master, config: '{{archer_a9_router_rebooter_config|to_json}}'}
|
|
- name: Insert into Postgres table service_data
|
|
community.postgresql.postgresql_query:
|
|
login_host: '{{homelab_config.database.host}}'
|
|
login_user: '{{homelab_config.database.user}}'
|
|
login_password: '{{homelab_config.database.password}}'
|
|
db: '{{homelab_config.database.name}}'
|
|
query: 'INSERT INTO service_data (service, data_name, storage_type, source) VALUES (%s, %s, %s, %s) ON CONFLICT DO NOTHING;'
|
|
positional_args:
|
|
- '{{item.service}}'
|
|
- '{{item.data_name}}'
|
|
- '{{item.storage_type}}'
|
|
- '{{item.source}}'
|
|
with_items:
|
|
- {service: archer_a9_router_rebooter, data_name: logs, storage_type: docker, source: archer-a9-router-rebooter-logs}
|