|
1 | | - - name: Deploy Nest to Production |
| 1 | + - name: Deploy Nest to Production # yamllint disable-line rule:indentation |
2 | 2 | hosts: production_nest |
3 | 3 | tasks: |
4 | 4 | - name: Copy docker-compose.yaml |
|
8 | 8 | mode: '0644' |
9 | 9 |
|
10 | 10 | - name: Sync Makefile structure |
11 | | - ansible.builtin.synchronize: |
| 11 | + ansible.posix.synchronize: |
12 | 12 | src: '{{ github_workspace }}/' |
13 | | - dest: '~/' |
14 | | - recursive: yes |
| 13 | + dest: ~/ |
| 14 | + recursive: true |
15 | 15 | rsync_opts: |
16 | | - - '--include=*/' |
17 | | - - '--include=Makefile' |
18 | | - - '--include=*/Makefile' |
19 | | - - '--include=*/**/Makefile' |
20 | | - - '--include=*/**/**/Makefile' |
21 | | - - '--exclude=*' |
22 | | - |
23 | | - - name: Update backend makefile for the production environment |
24 | | - shell: |
25 | | - cmd: sed -i 's/\bnest-backend\b/production-nest-backend/' ~/backend/Makefile |
| 16 | + - --include=*/ |
| 17 | + - --include=Makefile |
| 18 | + - --include=*/Makefile |
| 19 | + - --include=*/**/Makefile |
| 20 | + - --include=*/**/**/Makefile |
| 21 | + - --exclude=* |
26 | 22 |
|
27 | | - - name: Update frontend makefile for the production environment |
28 | | - shell: |
29 | | - cmd: sed -i 's/\bnest-frontend\b/production-nest-frontend/' ~/frontend/Makefile |
| 23 | + - name: Update Makefiles for production environment |
| 24 | + ansible.builtin.command: |
| 25 | + argv: |
| 26 | + - sed |
| 27 | + - -i |
| 28 | + - '{{ item.sed_expr }}' |
| 29 | + - '{{ item.path }}' |
| 30 | + loop: |
| 31 | + - sed_expr: /e2e-\|fuzz-/! s/\bnest-backend\b/production-nest-backend/g |
| 32 | + path: '{{ ansible_env.HOME }}/backend/Makefile' |
| 33 | + - sed_expr: /e2e-\|fuzz-/! s/\bnest-db\b/production-nest-db/g |
| 34 | + path: '{{ ansible_env.HOME }}/backend/Makefile' |
| 35 | + - sed_expr: s/\bnest-frontend\b/production-nest-frontend/g |
| 36 | + path: '{{ ansible_env.HOME }}/frontend/Makefile' |
| 37 | + changed_when: false |
30 | 38 |
|
31 | 39 | - name: Copy secrets |
32 | | - copy: |
| 40 | + ansible.builtin.copy: |
33 | 41 | src: '{{ github_workspace }}/{{ item }}' |
34 | 42 | dest: ~/ |
35 | 43 | mode: '0400' |
|
42 | 50 |
|
43 | 51 | - name: Clean up secrets |
44 | 52 | delegate_to: localhost |
45 | | - file: |
| 53 | + ansible.builtin.file: |
46 | 54 | path: '{{ github_workspace }}/{{ item }}' |
47 | 55 | state: absent |
48 | 56 | loop: |
|
51 | 59 | - .env.db |
52 | 60 | - .env.frontend |
53 | 61 | - .github.pem |
54 | | - run_once: true |
55 | 62 |
|
56 | 63 | - name: Copy crontab |
57 | | - copy: |
| 64 | + ansible.builtin.copy: |
58 | 65 | src: '{{ github_workspace }}/cron/production' |
59 | 66 | dest: /tmp/production_crontab |
60 | 67 | mode: '0600' |
61 | 68 |
|
62 | 69 | - name: Install crontab |
63 | 70 | ansible.builtin.command: |
64 | 71 | cmd: crontab /tmp/production_crontab |
| 72 | + changed_when: false |
65 | 73 |
|
66 | 74 | - name: Restart services |
67 | | - shell: |
| 75 | + ansible.builtin.command: |
68 | 76 | cmd: docker compose up -d --pull always |
| 77 | + changed_when: false |
69 | 78 |
|
70 | 79 | - name: Prune docker images |
71 | | - shell: |
| 80 | + ansible.builtin.command: |
72 | 81 | cmd: docker image prune -f |
| 82 | + changed_when: false |
73 | 83 |
|
74 | 84 | - name: Index data |
75 | | - async: 1800 # 30 minutes |
| 85 | + async: 1800 # 30 minutes |
76 | 86 | poll: 0 |
77 | | - shell: | |
| 87 | + # Shell required for stdout/stderr redirect to log file. |
| 88 | + ansible.builtin.shell: | |
78 | 89 | make index-data > /var/log/nest/production/index-data.log 2>&1 |
| 90 | + changed_when: false |
0 commit comments