Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/ansible/inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@ nest:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_private_key_file: "{{ lookup('env', 'NEST_SSH_PRIVATE_KEY_PATH') }}"
ansible_user: production

production_nest_proxy:
ansible_host: "{{ lookup('env', 'PROXY_HOST_IP_ADDRESS') }}"
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_private_key_file: "{{ lookup('env', 'PROXY_SSH_PRIVATE_KEY_PATH') }}"
ansible_user: proxy

staging_nest:
ansible_host: "{{ lookup('env', 'NEST_HOST_IP_ADDRESS') }}"
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_private_key_file: "{{ lookup('env', 'NEST_SSH_PRIVATE_KEY_PATH') }}"
ansible_user: staging

staging_nest_proxy:
ansible_host: "{{ lookup('env', 'PROXY_HOST_IP_ADDRESS') }}"
ansible_python_interpreter: /usr/bin/python3
Expand Down
194 changes: 88 additions & 106 deletions .github/ansible/production/nest.yaml
Original file line number Diff line number Diff line change
@@ -1,106 +1,88 @@
- name: Deploy Nest to Production
hosts: production_nest
tasks:
- name: Copy docker-compose.yaml
ansible.builtin.copy:
src: '{{ github_workspace }}/docker/docker-compose-production.yaml'
dest: ~/docker-compose.yaml
mode: '0644'

- name: Ensure backend directory exists
ansible.builtin.file:
path: ~/backend
state: directory
mode: '0755'

- name: Copy backend makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/backend/Makefile'
dest: ~/backend/Makefile
mode: '0644'

- name: Update backend makefile for the production environment
shell:
cmd: sed -i 's/\bnest-backend\b/production-nest-backend/' ~/backend/Makefile

- name: Ensure cspell directory exists
ansible.builtin.file:
path: ~/cspell
state: directory
mode: '0755'

- name: Copy cspell makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/cspell/Makefile'
dest: ~/cspell/Makefile
mode: '0644'

- name: Ensure frontend directory exists
ansible.builtin.file:
path: ~/frontend
state: directory
mode: '0755'

- name: Copy frontend makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/frontend/Makefile'
dest: ~/frontend/Makefile
mode: '0644'

- name: Update frontend makefile for the production environment
shell:
cmd: sed -i 's/\bnest-frontend\b/production-nest-frontend/' ~/frontend/Makefile

- name: Copy main makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/Makefile'
dest: ~/Makefile
mode: '0644'

- name: Ensure schema directory exists
ansible.builtin.file:
path: ~/schema
state: directory
mode: '0755'

- name: Copy schema makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/schema/Makefile'
dest: ~/schema/Makefile
mode: '0644'

- name: Copy directory recursively
copy:
src: '{{ github_workspace }}/backend/data'
dest: ~/
mode: '0755'

- name: Copy .env.backend
copy:
src: '{{ github_workspace }}/.env.backend'
dest: ~/
mode: '0400'

- name: Copy .env.db
copy:
src: '{{ github_workspace }}/.env.db'
dest: ~/
mode: '0400'

- name: Prune docker images
shell:
cmd: docker image prune -f

- name: Update Docker images
shell:
cmd: docker compose pull

- name: Retart services
shell:
cmd: docker compose up -d

- name: Index data
async: 1800 # 30 minutes
poll: 0
shell: |
make index-data > /var/log/nest/production/index-data.log 2>&1
- name: Deploy Nest to Production
hosts: production_nest
tasks:
- name: Copy docker-compose.yaml
ansible.builtin.copy:
src: '{{ github_workspace }}/docker/docker-compose-production.yaml'
dest: ~/docker-compose.yaml
mode: '0644'
- name: Ensure backend directory exists
ansible.builtin.file:
path: ~/backend
state: directory
mode: '0755'
- name: Copy backend makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/backend/Makefile'
dest: ~/backend/Makefile
mode: '0644'
- name: Update backend makefile for the production environment
shell:
cmd: sed -i 's/\bnest-backend\b/production-nest-backend/' ~/backend/Makefile
- name: Ensure cspell directory exists
ansible.builtin.file:
path: ~/cspell
state: directory
mode: '0755'
- name: Copy cspell makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/cspell/Makefile'
dest: ~/cspell/Makefile
mode: '0644'
- name: Ensure frontend directory exists
ansible.builtin.file:
path: ~/frontend
state: directory
mode: '0755'
- name: Copy frontend makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/frontend/Makefile'
dest: ~/frontend/Makefile
mode: '0644'
- name: Update frontend makefile for the production environment
shell:
cmd: sed -i 's/\bnest-frontend\b/production-nest-frontend/' ~/frontend/Makefile
- name: Copy main makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/Makefile'
dest: ~/Makefile
mode: '0644'
- name: Ensure schema directory exists
ansible.builtin.file:
path: ~/schema
state: directory
mode: '0755'
- name: Copy schema makefile
ansible.builtin.copy:
src: '{{ github_workspace }}/schema/Makefile'
dest: ~/schema/Makefile
mode: '0644'
- name: Copy directory recursively
copy:
src: '{{ github_workspace }}/backend/data'
dest: ~/
mode: '0755'
- name: Copy .env.backend
copy:
src: '{{ github_workspace }}/.env.backend'
dest: ~/
mode: '0400'
- name: Copy .env.db
copy:
src: '{{ github_workspace }}/.env.db'
dest: ~/
mode: '0400'
- name: Prune docker images
shell:
cmd: docker image prune -f
- name: Update Docker images
shell:
cmd: docker compose pull
- name: Retart services
shell:
cmd: docker compose up -d
- name: Index data
async: 1800 # 30 minutes
poll: 0
shell: |
make index-data > /var/log/nest/production/index-data.log 2>&1
41 changes: 19 additions & 22 deletions .github/ansible/production/proxy.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
- name: Deploy Production Nest Proxy
hosts: production_nest_proxy
tasks:
- name: Copy proxy docker-compose.yaml
ansible.builtin.copy:
src: '{{ github_workspace }}/proxy/docker-compose.yaml'
dest: ~/docker-compose.yaml
mode: '0644'

- name: Copy proxy configuration file
ansible.builtin.copy:
src: '{{ github_workspace }}/proxy/production.conf'
dest: ~/production.conf
mode: '0644'

- name: Update Docker images
shell:
cmd: docker compose pull

- name: Retart proxy server
shell:
cmd: docker compose restart
- name: Deploy Production Nest Proxy
hosts: production_nest_proxy
tasks:
- name: Copy proxy docker-compose.yaml
ansible.builtin.copy:
src: '{{ github_workspace }}/proxy/docker-compose.yaml'
dest: ~/docker-compose.yaml
mode: '0644'
- name: Copy proxy configuration file
ansible.builtin.copy:
src: '{{ github_workspace }}/proxy/production.conf'
dest: ~/production.conf
mode: '0644'
- name: Update Docker images
shell:
cmd: docker compose pull
- name: Retart proxy server
shell:
cmd: docker compose restart
16 changes: 8 additions & 8 deletions .github/ansible/production/sync-data.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: Run Nest Production Data Sync
hosts: production_nest
tasks:
- name: Sync Nest data
async: 72000 # 20 hours
poll: 0
shell: |
make sync-data > /var/log/nest/production/sync-data.log 2>&1
- name: Run Nest Production Data Sync
hosts: production_nest
tasks:
- name: Sync Nest data
async: 72000 # 20 hours
poll: 0
shell: |
make sync-data > /var/log/nest/production/sync-data.log 2>&1
Loading
Loading