~starkingdoms/starkingdoms

4b312c89225174ec940d281e46b4205c46e2328a — c0repwn3r 2 years ago 5a57ea9
deploy to all hosts
1 files changed, 91 insertions(+), 1 deletions(-)

M ansible/deploy.yaml
M ansible/deploy.yaml => ansible/deploy.yaml +91 -1
@@ 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