ovh_instance_playbooks/deploy_ovh_instance.yml

108 lines
3.2 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
- name: Remove old SSH host key
command: ssh-keygen -f "/home/{{ LINUX_USERNAME }}/.ssh/known_hosts" -R "{{ target_name }}"
changed_when: false
- 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:
tags: common
- 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:
tags: common
2024-03-22 20:46:39 +00:00
tags: common
- name: Include secrets from yml db
ansible.builtin.include_vars: "{{ local_workdir }}/secrets.yml"
2024-03-22 21:39:37 +00:00
tags: common
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-03-22 22:08:40 +00:00
tags: common
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-03-22 22:08:40 +00:00
tags: common
2024-03-22 20:46:39 +00:00
- name: Include role_configure_ovh_instance
ansible.builtin.include_role:
name: role_configure_ovh_instance
tags: configure
- 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
ansible.builtin.include_tasks: "tasks/deploy_mysql-server.yml"
tags: deploy_mysql-server
- name: Include deploy_gogs tasks
ansible.builtin.include_tasks: "tasks/deploy_gogs.yml"
tags: deploy_gogs
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-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