ansible-edda/plays/services/roles/deploy/lrproxy/tasks/main.yml

111 lines
3.9 KiB
YAML
Raw Normal View History

2022-12-16 21:23:24 +01:00
- name: "set the user variables"
ansible.builtin.import_role:
name: "include"
vars_from: "user"
2022-12-16 23:42:57 +01:00
- name: "set the version variables"
ansible.builtin.import_role:
name: "deploy/include"
vars_from: "versions"
2022-12-16 21:23:24 +01:00
- name: "set the rproxy variables"
2022-12-16 21:49:50 +01:00
ansible.builtin.include_vars:
file: "nginx.yml"
2022-12-16 21:23:24 +01:00
- block:
- name: "create nginx conf.d"
ansible.builtin.file:
path: "{{ services_service_user_home }}/.config/{{ services_service_user_name }}/nginx-conf.d"
state: "directory"
mode: 0755
- name: "configure reverse proxy nginx"
ansible.builtin.copy:
2022-12-16 23:27:09 +01:00
src: "./config/{{ item }}"
2022-12-16 21:23:24 +01:00
dest: "{{ services_service_user_home }}/.config/{{ services_service_user_name }}/{{ item }}"
mode: 0644
loop: "{{ services_rproxy_nginx_conf_d_files }}"
register: services_deploy_lrproxy_config_files
- name: "configure systemd service"
ansible.builtin.template:
src: "./systemd/{{ item }}.j2"
dest: "{{ services_service_user_home }}/.config/systemd/user/{{ item }}"
mode: 0600
2022-12-16 21:23:24 +01:00
loop:
- "pod-lrproxy.service"
- "container-lrproxy-nginx.service"
- "rsync-certificates.service"
- "rsync-certificates.timer"
register: services_deploy_lrproxy_systemd_files
- name: "systemd user daemon reload"
2022-12-16 22:16:23 +01:00
ansible.builtin.systemd:
2022-12-16 21:23:24 +01:00
daemon_reload: true
scope: "user"
when:
services_deploy_lrproxy_systemd_files.changed
- name: "enable rsync-certificates timer"
ansible.builtin.systemd:
name: "rsync-certificates.timer"
enabled: true
scope: "user"
register: services_deploy_lrproxy_rsync_certificates_timer
- name: "generate diffie hellman ephemeral parameters"
ansible.builtin.command: "openssl dhparam --out /{{ services_service_user_home }}/.config/{{ services_service_user_name}}/dhparam.pem 4096"
args:
creates: "{{ services_service_user_home }}/.config/{{ services_service_user_name }}/dhparam.pem"
register: services_deploy_lrproxy_dhparam
- name: "create the .ssh directory"
ansible.builtin.file:
path: "{{ services_service_user_home }}/.ssh"
state: "directory"
mode: 0700
- name: "generate ssh keypair for rsync"
community.crypto.openssh_keypair:
path: "{{ services_service_user_home }}/.ssh/valkyrie-pod-rproxy"
type: "ed25519"
register: services_deploy_lrproxy_keypair
- name: "configure public key on valkyrie"
delegate_to: valkyrie
become_user: pod-rproxy
ansible.posix.authorized_key:
user: "pod-rproxy"
state: "present"
key: "{{ services_deploy_lrproxy_keypair.public_key }}"
2022-12-18 00:05:58 +01:00
key_options: "command=\"rsync --server --sender -avz . {{ hostvars['valkyrie'].services_data_directory }}/pod-rproxy/etc-letsencrypt/\",from=\"{{ vpn_wireguard_address }}\",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-x11-forwarding"
2022-12-16 21:23:24 +01:00
- name: "enable the service"
ansible.builtin.systemd:
name: "pod-{{ services_service_name }}.service"
enabled: true
scope: "user"
- name: "start the service"
ansible.builtin.systemd:
name: "pod-{{ services_service_name }}.service"
state: "started"
scope: "user"
register: services_deploy_lrproxy_service_start
- name: "restart the service"
ansible.builtin.systemd:
name: "pod-{{ services_service_name }}.service"
state: "restarted"
scope: "user"
2022-12-16 21:23:24 +01:00
when:
(services_deploy_lrproxy_config_files.changed or
services_deploy_lrproxy_systemd_files.changed or
services_deploy_lrproxy_rsync_certificates_timer.changed or
services_deploy_lrproxy_dhparam.changed or
services_deploy_lrproxy_keypair.changed) and
not services_deploy_lrproxy_service_start.changed
become_user: "{{ services_service_user_name }}"