-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added github actions workflow for testing
- Loading branch information
Showing
3 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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,72 @@ | ||
--- | ||
name: GitOps | ||
|
||
on: | ||
push: | ||
branches: [main, development] | ||
pull_request: | ||
schedule: | ||
- cron: '53 1 */15 * *' | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/secshellnet/ansible-vyos-lint | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run ansible-lint | ||
run: | | ||
ansible-lint -x yaml[comments],yaml[empty-lines],\ | ||
yaml[new-line-at-end-of-file],yaml[trailing-spaces],\ | ||
var-spacing,command-instead-of-shell,no-changed-when,\ | ||
name[template],args[module] | ||
run: | ||
runs-on: ubuntu-latest | ||
needs: [lint] | ||
|
||
steps: | ||
- name: Check if GitOps is enabled | ||
run: | | ||
if [ "${{ env.ENABLE_GITOPS }}" != "1" ]; then | ||
echo "ENABLE_GITOPS is not set to true, workflow will terminate." | ||
exit 0 # Terminate the workflow successfully | ||
fi | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Prepare environment | ||
run: | | ||
mkdir .ssh | ||
echo "${{ secrets.SSH_KEY }}" > .keys/id_eddsa | ||
chmod 600 .ssh/id_ecdsa | ||
echo "${{ secrets.ANSIBLE_KEYS_ALL }}" > .keys/all | ||
git submodule update | ||
ansible-galaxy collection install hetzner.hcloud | ||
/opt/pipx/venvs/ansible-core/bin/python -m pip install -r requirements.txt | ||
- name: Check target reachability | ||
continue-on-error: true | ||
env: | ||
ANSIBLE_HOST_KEY_CHECKING: false | ||
run: | | ||
ansible -m ping all | ||
- name: Run ansible inventory in check mode | ||
if: ${{ github.event_name == 'pull_request' }} | ||
env: | ||
ANSIBLE_HOST_KEY_CHECKING: false | ||
run: | | ||
ansible-playbook servers.yaml --check | ||
- name: Deploy ansible inventory | ||
if: ${{ github.event_name != 'pull_request' }} | ||
env: | ||
ANSIBLE_HOST_KEY_CHECKING: false | ||
run: | | ||
ansible-playbook servers.yaml |
This file contains 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 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 @@ | ||
ipaddress | ||
passlib |