ovh_instance_playbooks/deploy_ovh_instance.yml

174 lines
4.7 KiB
YAML
Raw Normal View History

2024-03-22 20:46:39 +00:00
- name: deploy OVH instance
hosts: localhost
tags: create
vars_files:
- vars/main.yml
tasks:
- name: Retrieve secrets
ansible.builtin.include_tasks: "tasks/retrieve_secret_vars.yml"
- name: Include OVH application credentials
ansible.builtin.include_vars: "{{ remote_workdir }}/OVH_APPLICATION.yml"
- name: include role_deploy_openstack_instance
ansible.builtin.include_role:
name: role_deploy_openstack_instance
- name: add new instance to host group at runtime
ansible.builtin.add_host:
name: "{{ target_name }}"
ansible_host: "{{ openstack_output.openstack.accessIPv4 }}"
groups: target
2024-03-24 14:03:21 +00:00
changed_when: false
2024-03-22 20:46:39 +00:00
- name: Remove old SSH host key
2024-03-29 21:11:13 +00:00
command: ssh-keygen -f "/home/{{ LINUX_USERNAME }}/.ssh/known_hosts" -R "{{ item }}"
2024-03-22 20:46:39 +00:00
changed_when: false
2024-03-29 21:11:13 +00:00
with_items:
- "{{ target_name }}"
- "{{ openstack_output.openstack.accessIPv4 }}"
2024-03-22 20:46:39 +00:00
- name: configure OVH instance
hosts: target
vars_files:
- vars/main.yml
gather_facts: false
tasks:
- name: Wait for system to become reachable
ansible.builtin.wait_for_connection:
timeout: 30
tags: configure
- name: Gather facts
ansible.builtin.setup:
2024-06-15 16:04:36 +00:00
tags:
- common
- always
2024-03-22 20:46:39 +00:00
- name: Include retrieve_secret_vars tasks
2024-03-22 21:48:08 +00:00
ansible.builtin.include_tasks:
file: "tasks/retrieve_secret_vars.yml"
apply:
2024-06-15 16:04:36 +00:00
tags:
- common
- always
tags:
- common
- always
2024-03-22 20:46:39 +00:00
- name: Include secrets from yml db
ansible.builtin.include_vars: "{{ local_workdir }}/secrets.yml"
2024-06-15 16:04:36 +00:00
tags:
- common
- always
2024-03-22 20:46:39 +00:00
- name: Register variable DUPLICITY_PASSPHRASE
command: "cat {{ remote_workdir }}/duplicity_passphrase"
register: cat_duplicity_passphrase
changed_when: false
2024-06-15 16:04:36 +00:00
tags:
- common
- always
2024-03-22 20:46:39 +00:00
- name: Set variable DUPLICITY_PASSPHRASE
set_fact:
"DUPLICITY_PASSPHRASE": "{{ cat_duplicity_passphrase.stdout }}"
changed_when: false
2024-06-15 16:04:36 +00:00
tags:
- common
- always
2024-03-22 20:46:39 +00:00
- name: Include role_configure_ovh_instance
ansible.builtin.include_role:
name: role_configure_ovh_instance
2024-06-15 16:04:36 +00:00
apply:
tags: common
tags: common
2024-03-22 20:46:39 +00:00
- name: switch to new user
set_fact:
ansible_user: "{{ LINUX_USERNAME }}"
2024-06-15 16:04:36 +00:00
tags:
- common
- always
2024-03-22 20:46:39 +00:00
- name: Include deploy_reverse-proxy tasks
ansible.builtin.include_tasks: "tasks/deploy_reverse-proxy.yml"
tags: deploy_reverse-proxy
- name: Include deploy_mysql-server tasks
2024-06-15 16:04:36 +00:00
ansible.builtin.include_tasks:
file: "tasks/deploy_mysql-server.yml"
apply:
tags: deploy_mysql-server
2024-03-22 20:46:39 +00:00
tags: deploy_mysql-server
- name: Include deploy_gogs tasks
2024-06-15 16:04:36 +00:00
ansible.builtin.include_tasks:
file: "tasks/deploy_gogs.yml"
apply:
tags: deploy_gogs
2024-03-22 20:46:39 +00:00
tags: deploy_gogs
2024-03-24 14:03:21 +00:00
- name: Include role_deploy_registry
ansible.builtin.include_role:
name: role_deploy_registry
apply:
tags: deploy_registry
tags: deploy_registry
2024-03-22 21:30:25 +00:00
- name: Include role_deploy_nextcloud
ansible.builtin.include_role:
name: role_deploy_nextcloud
2024-03-22 21:39:37 +00:00
apply:
tags: deploy_nextcloud
2024-03-22 21:30:25 +00:00
tags: deploy_nextcloud
2024-03-24 07:42:57 +00:00
- name: Include role_deploy_grafana
ansible.builtin.include_role:
name: role_deploy_grafana
apply:
tags: deploy_grafana
tags: deploy_grafana
2024-03-30 15:43:48 +00:00
- name: Include role_deploy_coturn
ansible.builtin.include_role:
name: role_deploy_coturn
apply:
tags: deploy_coturn
tags: deploy_coturn
2024-03-31 16:02:37 +00:00
- name: Include role_deploy_SemanticScuttle
ansible.builtin.include_role:
name: role_deploy_SemanticScuttle
apply:
tags: deploy_SemanticScuttle
tags: deploy_SemanticScuttle
2024-06-15 14:59:08 +00:00
- name: Include role_deploy_openvpn-server
ansible.builtin.include_role:
name: role_deploy_openvpn-server
apply:
tags: deploy_openvpn-server
tags: deploy_openvpn-server
2024-03-22 20:46:39 +00:00
- name: delete OVH instance
hosts: localhost
connection: local
tags: delete
vars_files:
- vars/main.yml
tasks:
- name: Retrieve secrets
ansible.builtin.include_tasks: "tasks/retrieve_secret_vars.yml"
when: delete | default(True) | bool
- name: Include OVH application credentials
ansible.builtin.include_vars: "{{ remote_workdir }}/OVH_APPLICATION.yml"
when: delete | default(True) | bool
- name: include role_delete_openstack_instance
ansible.builtin.include_role:
name: role_delete_openstack_instance
when: delete | default(True) | bool