archer-a9-router-rebooter/start.yaml

40 lines
1.5 KiB
YAML

- name: Start Archer A9 Router Rebooter
hosts: Rivendell
tasks:
- 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: Get Archer A9 Router Rebooter config
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: 'SELECT config FROM service WHERE name = %s;'
positional_args:
- archer_a9_router_rebooter
register: archer_a9_router_rebooter_config_query
- name: Set archer_a9_router_rebooter_config variable
ansible.builtin.set_fact:
archer_a9_router_rebooter_config: '{{archer_a9_router_rebooter_config_query.query_result[0].config}}'
- name: Start Archer A9 Router Rebooter Docker container
community.docker.docker_container:
name: archer-a9-router-rebooter
image: archer-a9-router-rebooter:latest
restart_policy: unless-stopped
env:
ROUTER_IP: 192.168.0.1
ROUTER_PASSWORD: '{{archer_a9_router_rebooter_config.router.password}}'
volumes:
- archer-a9-router-rebooter-logs:/logs
- /etc/localtime:/etc/localtime:ro
network_mode: host
keep_volumes: false
state: started