From 4b312c89225174ec940d281e46b4205c46e2328a Mon Sep 17 00:00:00 2001 From: c0repwn3r Date: Fri, 21 Apr 2023 19:05:27 -0400 Subject: [PATCH] deploy to all hosts --- ansible/deploy.yaml | 92 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/ansible/deploy.yaml b/ansible/deploy.yaml index 2f28db895211c37ed008885d13c935fa1a3a5977..34cffe7c59af0d0431c067a32e78564b87e7d999 100644 --- a/ansible/deploy.yaml +++ b/ansible/deploy.yaml @@ -52,12 +52,102 @@ - name: Deploy beta servers hosts: starkingdoms_prod_servers_beta + vars: + # Randomly generated per-deployment secrets + api_key: "{{ lookup('community.general.random_string', base64=True, length=24) }}" + jwt_signing_secret: "{{ lookup('community.general.random_string', base64=True, length=24) }}" + + # Database info + db_name: starkingdoms-bleeding + + # What version of the docker container should be deployed? + version: beta + + ws_port: 3204 + api_port: 3205 + web_port: 3206 + + api_config_dir: /home/stk-deploy/config + db_data_dir: /home/stk-deploy/data + compose_dir: /home/stk-deploy + + api_url: https://api.beta.starkingdoms.tk + game_url: https://beta.starkingdoms.tk tasks: - name: Ensure host connectivity ansible.builtin.ping: + - name: Create configuration directory + ansible.builtin.file: + path: "{{ api_config_dir }}" + state: directory + mode: 0755 + - name: Create data directory + ansible.builtin.file: + path: "{{ db_data_dir }}" + state: directory + mode: 0755 + - name: Create API config file + ansible.builtin.template: + src: ../docker/config.jinja.toml + dest: "{{ api_config_dir }}/config.toml" + force: no + - name: Create docker-compose config file + ansible.builtin.template: + src: ../docker/docker-compose.jinja.yml + dest: "{{ compose_dir }}/docker-compose.yml" + force: no + - name: Start the server + ansible.builtin.shell: + cmd: docker-compose up -d + chdir: "{{ compose_dir }}" - name: Deploy stable servers hosts: starkingdoms_prod_servers_stable + vars: + # Randomly generated per-deployment secrets + api_key: "{{ lookup('community.general.random_string', base64=True, length=24) }}" + jwt_signing_secret: "{{ lookup('community.general.random_string', base64=True, length=24) }}" + + # Database info + db_name: starkingdoms-bleeding + + # What version of the docker container should be deployed? + version: stable + + ws_port: 3204 + api_port: 3205 + web_port: 3206 + + api_config_dir: /home/stk-deploy/config + db_data_dir: /home/stk-deploy/data + compose_dir: /home/stk-deploy + + api_url: https://api.starkingdoms.tk + game_url: https://starkingdoms.tk tasks: - name: Ensure host connectivity - ansible.builtin.ping: \ No newline at end of file + ansible.builtin.ping: + - name: Create configuration directory + ansible.builtin.file: + path: "{{ api_config_dir }}" + state: directory + mode: 0755 + - name: Create data directory + ansible.builtin.file: + path: "{{ db_data_dir }}" + state: directory + mode: 0755 + - name: Create API config file + ansible.builtin.template: + src: ../docker/config.jinja.toml + dest: "{{ api_config_dir }}/config.toml" + force: no + - name: Create docker-compose config file + ansible.builtin.template: + src: ../docker/docker-compose.jinja.yml + dest: "{{ compose_dir }}/docker-compose.yml" + force: no + - name: Start the server + ansible.builtin.shell: + cmd: docker-compose up -d + chdir: "{{ compose_dir }}" \ No newline at end of file