-
-
Notifications
You must be signed in to change notification settings - Fork 521
CI: Add ansible-lint workflow for Ansible playbooks #3796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arkid15r
merged 16 commits into
OWASP:main
from
hassaansaleem28:ci/3747-ansible-linting-addition
Feb 9, 2026
+234
−151
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4357a49
ci: add ansible-lint workflow
hassaansaleem28 54421b0
Merge branch 'main' into ci/3747-ansible-linting-addition
hassaansaleem28 41468fb
Update .github/workflows/lint-ansible.yaml
hassaansaleem28 d591f4e
ci: add ansible-lint make target and workflow
hassaansaleem28 3aeb9d4
ci: add ansible-lint pre-commit hook
hassaansaleem28 a3fa91f
Merge branch 'main' into ci/3747-ansible-linting-addition
hassaansaleem28 b3d73a6
fix: whitespace & version
hassaansaleem28 7a41d02
Update Makefile
hassaansaleem28 8bbe0af
ci: enable ansible-lint scanning and add requirements.yml
hassaansaleem28 e4eff88
Merge branch 'main' into ci/3747-ansible-linting-addition
hassaansaleem28 0dc210f
chore(ansible):align linting and module usage
hassaansaleem28 5d148fc
Merge branch 'main' into ci/3747-ansible-linting-addition
hassaansaleem28 f2ea71b
ci(ansible): install collections before deploy playbooks
hassaansaleem28 27e6d1f
Update code
arkid15r d9ae9d7
Update code
arkid15r 8ddc926
Update .github/workflows/run-ci-cd.yaml
arkid15r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,76 +1,90 @@ | ||
| - name: Deploy Nest to Production | ||
| hosts: production_nest | ||
| tasks: | ||
| - name: Copy docker-compose.yaml | ||
| ansible.builtin.copy: | ||
| src: '{{ github_workspace }}/docker-compose/production/compose.yaml' | ||
| dest: ~/docker-compose.yaml | ||
| mode: '0644' | ||
| - name: Deploy Nest to Production | ||
| hosts: production_nest | ||
| tasks: | ||
| - name: Copy docker-compose.yaml | ||
| ansible.builtin.copy: | ||
| src: '{{ github_workspace }}/docker-compose/production/compose.yaml' | ||
| dest: ~/docker-compose.yaml | ||
| mode: '0644' | ||
|
|
||
| - name: Sync Makefile structure | ||
| ansible.builtin.synchronize: | ||
| src: '{{ github_workspace }}/' | ||
| dest: '~/' | ||
| recursive: yes | ||
| rsync_opts: | ||
| - '--include=*/' | ||
| - '--include=Makefile' | ||
| - '--include=*/Makefile' | ||
| - '--include=*/**/Makefile' | ||
| - '--include=*/**/**/Makefile' | ||
| - '--exclude=*' | ||
| - name: Sync Makefile structure | ||
| ansible.posix.synchronize: | ||
| src: '{{ github_workspace }}/' | ||
| dest: '~/' | ||
| recursive: true | ||
| rsync_opts: | ||
| - '--include=*/' | ||
| - '--include=Makefile' | ||
| - '--include=*/Makefile' | ||
| - '--include=*/**/Makefile' | ||
| - '--include=*/**/**/Makefile' | ||
| - '--exclude=*' | ||
|
|
||
| - name: Update Makefiles for production environment | ||
| shell: | | ||
| sed -i '/e2e-\|fuzz-/! s/\bnest-backend\b/production-nest-backend/g' ~/backend/Makefile | ||
| sed -i '/e2e-\|fuzz-/! s/\bnest-db\b/production-nest-db/g' ~/backend/Makefile | ||
| sed -i 's/\bnest-frontend\b/production-nest-frontend/g' ~/frontend/Makefile | ||
| - name: Update Makefiles for production environment | ||
| ansible.builtin.command: | ||
| argv: | ||
| - sed | ||
| - -i | ||
| - "{{ item.sed_expr }}" | ||
| - "{{ item.path }}" | ||
| loop: | ||
| - sed_expr: '/e2e-\|fuzz-/! s/\bnest-backend\b/production-nest-backend/g' | ||
| path: '{{ ansible_env.HOME }}/backend/Makefile' | ||
| - sed_expr: '/e2e-\|fuzz-/! s/\bnest-db\b/production-nest-db/g' | ||
| path: '{{ ansible_env.HOME }}/backend/Makefile' | ||
| - sed_expr: 's/\bnest-frontend\b/production-nest-frontend/g' | ||
| path: '{{ ansible_env.HOME }}/frontend/Makefile' | ||
| changed_when: false | ||
|
|
||
| - name: Copy secrets | ||
| copy: | ||
| src: '{{ github_workspace }}/{{ item }}' | ||
| dest: ~/ | ||
| mode: '0400' | ||
| loop: | ||
| - .env.backend | ||
| - .env.cache | ||
| - .env.db | ||
| - .env.frontend | ||
| - .github.pem | ||
| - name: Copy secrets | ||
| ansible.builtin.copy: | ||
| src: '{{ github_workspace }}/{{ item }}' | ||
| dest: ~/ | ||
| mode: '0400' | ||
| loop: | ||
| - .env.backend | ||
| - .env.cache | ||
| - .env.db | ||
| - .env.frontend | ||
| - .github.pem | ||
|
|
||
| - name: Clean up secrets | ||
| delegate_to: localhost | ||
| file: | ||
| path: '{{ github_workspace }}/{{ item }}' | ||
| state: absent | ||
| loop: | ||
| - .env.backend | ||
| - .env.cache | ||
| - .env.db | ||
| - .env.frontend | ||
| - .github.pem | ||
| run_once: true | ||
| - name: Clean up secrets | ||
| delegate_to: localhost | ||
| ansible.builtin.file: | ||
| path: '{{ github_workspace }}/{{ item }}' | ||
| state: absent | ||
| loop: | ||
| - .env.backend | ||
| - .env.cache | ||
| - .env.db | ||
| - .env.frontend | ||
| - .github.pem | ||
|
|
||
| - name: Copy crontab | ||
| copy: | ||
| src: '{{ github_workspace }}/cron/production' | ||
| dest: /tmp/production_crontab | ||
| mode: '0600' | ||
| - name: Copy crontab | ||
| ansible.builtin.copy: | ||
| src: '{{ github_workspace }}/cron/production' | ||
| dest: /tmp/production_crontab | ||
| mode: '0600' | ||
|
|
||
| - name: Install crontab | ||
| ansible.builtin.command: | ||
| cmd: crontab /tmp/production_crontab | ||
| - name: Install crontab | ||
| ansible.builtin.command: | ||
| cmd: crontab /tmp/production_crontab | ||
| changed_when: false | ||
|
|
||
| - name: Restart services | ||
| shell: | ||
| cmd: docker compose up -d --pull always | ||
| - name: Restart services | ||
| ansible.builtin.command: | ||
| cmd: docker compose up -d --pull always | ||
| changed_when: false | ||
|
|
||
| - name: Prune docker images | ||
| shell: | ||
| cmd: docker image prune -f | ||
| - name: Prune docker images | ||
| ansible.builtin.command: | ||
| cmd: docker image prune -f | ||
| changed_when: false | ||
|
|
||
| - name: Index data | ||
| async: 1800 # 30 minutes | ||
| poll: 0 | ||
| shell: | | ||
| make index-data > /var/log/nest/production/index-data.log 2>&1 | ||
| - name: Index data | ||
| async: 1800 # 30 minutes | ||
| poll: 0 | ||
| # Shell required for stdout/stderr redirect to log file. | ||
| ansible.builtin.shell: | | ||
| make index-data > /var/log/nest/production/index-data.log 2>&1 | ||
| changed_when: false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| collections: | ||
| - name: ansible.posix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,80 +1,94 @@ | ||
| - name: Deploy Nest to Staging | ||
| hosts: staging_nest | ||
| tasks: | ||
| - name: Copy docker-compose.yaml | ||
| ansible.builtin.copy: | ||
| src: '{{ github_workspace }}/docker-compose/staging/compose.yaml' | ||
| dest: ~/docker-compose.yaml | ||
| mode: '0644' | ||
| - name: Deploy Nest to Staging | ||
| hosts: staging_nest | ||
| tasks: | ||
| - name: Copy docker-compose.yaml | ||
| ansible.builtin.copy: | ||
| src: '{{ github_workspace }}/docker-compose/staging/compose.yaml' | ||
| dest: ~/docker-compose.yaml | ||
| mode: '0644' | ||
|
|
||
| - name: Sync Makefile structure | ||
| ansible.builtin.synchronize: | ||
| src: '{{ github_workspace }}/' | ||
| dest: '~/' | ||
| recursive: yes | ||
| rsync_opts: | ||
| - '--include=*/' | ||
| - '--include=Makefile' | ||
| - '--include=*/Makefile' | ||
| - '--include=*/**/Makefile' | ||
| - '--include=*/**/**/Makefile' | ||
| - '--exclude=*' | ||
| - name: Sync Makefile structure | ||
| ansible.posix.synchronize: | ||
| src: '{{ github_workspace }}/' | ||
| dest: '~/' | ||
| recursive: true | ||
| rsync_opts: | ||
| - '--include=*/' | ||
| - '--include=Makefile' | ||
| - '--include=*/Makefile' | ||
| - '--include=*/**/Makefile' | ||
| - '--include=*/**/**/Makefile' | ||
| - '--exclude=*' | ||
|
|
||
| - name: Update Makefiles for staging environment | ||
| shell: | | ||
| sed -i '/e2e-\|fuzz-/! s/\bnest-backend\b/staging-nest-backend/g' ~/backend/Makefile | ||
| sed -i '/e2e-\|fuzz-/! s/\bnest-db\b/staging-nest-db/g' ~/backend/Makefile | ||
| sed -i 's/\bnest-frontend\b/staging-nest-frontend/g' ~/frontend/Makefile | ||
| - name: Update Makefiles for staging environment | ||
| ansible.builtin.command: | ||
| argv: | ||
| - sed | ||
| - -i | ||
| - "{{ item.sed_expr }}" | ||
| - "{{ item.path }}" | ||
| loop: | ||
| - sed_expr: '/e2e-\|fuzz-/! s/\bnest-backend\b/staging-nest-backend/g' | ||
| path: '{{ ansible_env.HOME }}/backend/Makefile' | ||
| - sed_expr: '/e2e-\|fuzz-/! s/\bnest-db\b/staging-nest-db/g' | ||
| path: '{{ ansible_env.HOME }}/backend/Makefile' | ||
| - sed_expr: 's/\bnest-frontend\b/staging-nest-frontend/g' | ||
| path: '{{ ansible_env.HOME }}/frontend/Makefile' | ||
| changed_when: false | ||
|
|
||
| - name: Ensure data directory exists | ||
| ansible.builtin.file: | ||
| path: ~/backend/data | ||
| state: directory | ||
| mode: '0755' | ||
| - name: Ensure data directory exists | ||
| ansible.builtin.file: | ||
| path: ~/backend/data | ||
| state: directory | ||
| mode: '0755' | ||
|
|
||
| - name: Copy secrets | ||
| copy: | ||
| src: '{{ github_workspace }}/{{ item }}' | ||
| dest: ~/ | ||
| mode: '0400' | ||
| loop: | ||
| - .env.backend | ||
| - .env.cache | ||
| - .env.db | ||
| - .env.frontend | ||
| - name: Copy secrets | ||
| ansible.builtin.copy: | ||
| src: '{{ github_workspace }}/{{ item }}' | ||
| dest: ~/ | ||
| mode: '0400' | ||
| loop: | ||
| - .env.backend | ||
| - .env.cache | ||
| - .env.db | ||
| - .env.frontend | ||
|
|
||
| - name: Clean up secrets | ||
| delegate_to: localhost | ||
| file: | ||
| path: '{{ github_workspace }}/{{ item }}' | ||
| state: absent | ||
| loop: | ||
| - .env.backend | ||
| - .env.cache | ||
| - .env.db | ||
| - .env.frontend | ||
| run_once: true | ||
| - name: Clean up secrets | ||
arkid15r marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| delegate_to: localhost | ||
| ansible.builtin.file: | ||
| path: '{{ github_workspace }}/{{ item }}' | ||
| state: absent | ||
| loop: | ||
| - .env.backend | ||
| - .env.cache | ||
| - .env.db | ||
| - .env.frontend | ||
|
|
||
| - name: Copy crontab | ||
| copy: | ||
| src: '{{ github_workspace }}/cron/staging' | ||
| dest: /tmp/staging_crontab | ||
| mode: '0600' | ||
| - name: Copy crontab | ||
| ansible.builtin.copy: | ||
| src: '{{ github_workspace }}/cron/staging' | ||
| dest: /tmp/staging_crontab | ||
| mode: '0600' | ||
|
|
||
| - name: Install crontab | ||
| ansible.builtin.command: | ||
| cmd: crontab /tmp/staging_crontab | ||
| - name: Install crontab | ||
| ansible.builtin.command: | ||
| cmd: crontab /tmp/staging_crontab | ||
| changed_when: false | ||
|
|
||
| - name: Restart services | ||
| shell: | ||
| cmd: docker compose up -d --pull always | ||
| - name: Restart services | ||
| ansible.builtin.command: | ||
| cmd: docker compose up -d --pull always | ||
| changed_when: false | ||
|
|
||
| - name: Prune docker images | ||
| shell: | ||
| cmd: docker image prune -f | ||
| - name: Prune docker images | ||
| ansible.builtin.command: | ||
| cmd: docker image prune -f | ||
| changed_when: false | ||
|
|
||
| - name: Index data | ||
| async: 1800 # 30 minutes | ||
| poll: 0 | ||
| shell: | | ||
| make index-data > /var/log/nest/staging/index-data.log 2>&1 | ||
| - name: Index data | ||
| async: 1800 # 30 minutes | ||
| poll: 0 | ||
| # Shell required for stdout/stderr redirect to log file. | ||
| ansible.builtin.shell: | | ||
| make index-data > /var/log/nest/staging/index-data.log 2>&1 | ||
| changed_when: false | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.