2024-09-18 12:10:57 +00:00
|
|
|
- name: Install Stack Orchestrator if it isn't present
|
|
|
|
import_playbook: ../stack-orchestrator-setup/setup-laconic-so.yml
|
|
|
|
|
|
|
|
- name: Setup k8s
|
|
|
|
hosts: "{{ target_host }}"
|
|
|
|
|
2024-09-18 13:35:37 +00:00
|
|
|
vars_files:
|
|
|
|
- k8s-vars.yml
|
2024-09-19 06:59:13 +00:00
|
|
|
- dns-vars.yml
|
2024-09-18 12:10:57 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Install Python and pip
|
|
|
|
apt:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
become: true
|
|
|
|
loop:
|
|
|
|
- python3
|
|
|
|
- python3-pip
|
|
|
|
|
|
|
|
- name: Install Ansible on remote host
|
|
|
|
pip:
|
|
|
|
name: ansible
|
|
|
|
extra_args: --user
|
|
|
|
when: target_host != "localhost"
|
|
|
|
|
|
|
|
- name: Ensure ~/.local/bin is in PATH in .bashrc
|
|
|
|
lineinfile:
|
|
|
|
path: ~/.bashrc
|
|
|
|
line: 'export PATH="$HOME/.local/bin:$PATH"'
|
|
|
|
state: present
|
|
|
|
create: yes
|
2024-09-18 13:35:37 +00:00
|
|
|
|
|
|
|
- name: Clone the service provider template repo
|
|
|
|
git:
|
|
|
|
repo: "https://git.vdb.to/cerc-io/service-provider-template.git"
|
|
|
|
dest: "{{ ansible_env.HOME }}/service-provider-template"
|
|
|
|
|
|
|
|
- name: Update .vault/vault-keys file
|
|
|
|
lineinfile:
|
|
|
|
path: "service-provider-template/.vault/vault-keys"
|
|
|
|
regexp: '^.*$'
|
|
|
|
line: "{{ gpg_key_id }}"
|
|
|
|
create: yes
|
|
|
|
|
|
|
|
- name: Start GPG agent
|
|
|
|
command: gpg-agent --daemon
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Set VAULT_KEY environment variable
|
|
|
|
shell: export VAULT_KEY='{{ vault_passphrase }}'
|
|
|
|
|
|
|
|
- name: Run vault-rekey.sh
|
|
|
|
expect:
|
|
|
|
command: bash .vault/vault-rekey.sh
|
|
|
|
responses:
|
|
|
|
"Enter passphrase:": "{{ vault_passphrase }}"
|
|
|
|
args:
|
|
|
|
chdir: "service-provider-template"
|
2024-09-19 06:59:13 +00:00
|
|
|
|
|
|
|
- name: Ensure the target directory exists
|
|
|
|
file:
|
|
|
|
path: "{{ ansible_env.HOME }}/service-provider-template"
|
|
|
|
state: directory
|
|
|
|
mode: '0755'
|
|
|
|
|
|
|
|
- name: Change directory name in group_vars
|
|
|
|
command: mv lcn_cad {{ org_id }}_{{ location_id }}
|
|
|
|
args:
|
|
|
|
chdir: "{{ ansible_env.HOME }}/service-provider-template/group_vars"
|
|
|
|
|
|
|
|
- name: Change control directory name in host_vars
|
|
|
|
command: mv lcn-cad-cluster-control {{ org_id }}-{{ location_id }}-cluster-control
|
|
|
|
args:
|
|
|
|
chdir: "{{ ansible_env.HOME }}/service-provider-template/host_vars"
|
|
|
|
|
|
|
|
- name: Change daemon directory name in host_vars
|
|
|
|
command: mv lcn-daemon {{ org_id }}-daemon
|
|
|
|
args:
|
|
|
|
chdir: "{{ ansible_env.HOME }}/service-provider-template/host_vars"
|
|
|
|
|
|
|
|
- name: Copy control-firewalld.yml.j2 to the remote VM
|
|
|
|
template:
|
|
|
|
src: ./templates/control-firewalld.yml.j2
|
|
|
|
dest: "{{ ansible_env.HOME }}/service-provider-template/host_vars/{{ org_id }}-{{ location_id }}-cluster-control/firewalld.yml"
|
|
|
|
|
|
|
|
- name: Copy daemon-firewalld.yml.j2 to the remote VM
|
|
|
|
template:
|
|
|
|
src: ./templates/daemon-firewalld.yml.j2
|
|
|
|
dest: "{{ ansible_env.HOME }}/service-provider-template/host_vars/{{ org_id }}-daemon/firewalld.yml"
|
|
|
|
|
|
|
|
- name: Copy nginx.yml.j2 to the remote VM
|
|
|
|
template:
|
|
|
|
src: ./templates/nginx.yml.j2
|
|
|
|
dest: "{{ ansible_env.HOME }}/service-provider-template/host_vars/{{ org_id }}-daemon/nginx.yml"
|
|
|
|
|
|
|
|
- name: Copy hosts.j2 to the remote VM
|
|
|
|
template:
|
|
|
|
src: ./templates/hosts.j2
|
|
|
|
dest: "{{ ansible_env.HOME }}/service-provider-template/hosts"
|
|
|
|
|
|
|
|
- name: Copy k8s.yml.j2 to the remote VM
|
|
|
|
template:
|
|
|
|
src: ./templates/k8s.yml.j2
|
|
|
|
dest: "{{ ansible_env.HOME }}/service-provider-template/group_vars/{{ org_id }}_{{ location_id }}/k8s.yml"
|
|
|
|
|
|
|
|
- name: Copy wildcard-pwa-example.yml.j2 to the remote VM
|
|
|
|
template:
|
|
|
|
src: ./templates/wildcard-pwa-example.yml.j2
|
|
|
|
dest: "{{ ansible_env.HOME }}/service-provider-template/files/manifests/wildcard-pwa-{{dns_domain}}.yml"
|
|
|
|
|
|
|
|
- name: Delete old wildcard-pwa file
|
|
|
|
file:
|
|
|
|
path: "{{ ansible_env.HOME }}/service-provider-template/files/manifests/wildcard-pwa-laconic.yaml"
|
|
|
|
state: absent
|