From c918e5761cc5297caced4feceb1d720f9d121051 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Mon, 28 Aug 2023 23:59:57 +0100 Subject: [PATCH 01/14] initial --- .github/workflows/infra.yaml | 45 +++++++++++++++++++++++++++++ infra/test-vm/proxmox-playbook.yaml | 24 +++++++++++++++ inventory/proxmox.yaml | 12 ++++++++ 3 files changed, 81 insertions(+) create mode 100644 .github/workflows/infra.yaml create mode 100644 infra/test-vm/proxmox-playbook.yaml create mode 100644 inventory/proxmox.yaml diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml new file mode 100644 index 0000000..52c9251 --- /dev/null +++ b/.github/workflows/infra.yaml @@ -0,0 +1,45 @@ +name: Infrastructure +on: + pull_request: + branches: + - main + push: + branches: + - main + tags: + - infra/** + paths: + - infra/**-playbook.yaml + - .github/workflows/infra.yaml + +jobs: + check: + name: Check infrastructure definitions + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: -| + python3 -m venv venv + source venv/bin/activate + pip3 install -r requirements.txt + ansible-galaxy collection install community.general + + - name: Get changed playbooks + id: changed-playbooks + uses: tj-actions/changed-files@v38 + with: + files: infra/**-playbook.yaml + + - name: Check modified playbooks + run: -| + for file in ${{ steps.changed-playbooks.outputs.all_changed_files }}; do + ansible --inventory ./inventory --check "$file" + done diff --git a/infra/test-vm/proxmox-playbook.yaml b/infra/test-vm/proxmox-playbook.yaml new file mode 100644 index 0000000..e8c20bf --- /dev/null +++ b/infra/test-vm/proxmox-playbook.yaml @@ -0,0 +1,24 @@ +- name: Proxmox test-vm + hosts: localhost + module_defaults: + community.general.proxmox_kvm: + api_user: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_ID') | regex_replace('!.*') }}" + api_host: "{{ lookup('ansible.builtin.env', 'PROXMOX_HOST' ) }}" + api_token_id: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_ID') | regex_replace('.*!') }}" + api_token_secret: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_SECRET') }}" + name: test-vm + node: pve + tasks: + - name: Create test-vm + community.general.proxmox_kvm: + name: test-vm + node: pve + - name: Update test-vm + community.general.proxmox_kvm: + cpu: x86-64-v3 + memory: 2048 + cores: 3 + update: true + - name: Start test-vm + community.general.proxmox_kvm: + state: started diff --git a/inventory/proxmox.yaml b/inventory/proxmox.yaml new file mode 100644 index 0000000..6b4033d --- /dev/null +++ b/inventory/proxmox.yaml @@ -0,0 +1,12 @@ +proxmox: + children: + kovalhome: + children: + nodes: + hosts: + pve.mgmt.home.local.koval.net: + pve2.mgmt.home.local.koval.net: + managed: + hosts: + unmanaged: + hosts: -- 2.40.1 From 6e29e43ac038b05c2d18a8ef0d3c4b9ce557e4c1 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:04:15 +0100 Subject: [PATCH 02/14] fix setup python --- .github/workflows/infra.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 52c9251..b5be677 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -23,7 +23,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: ">=3.11" - name: Install dependencies run: -| -- 2.40.1 From eb68d6529f609b7ee2830adcd80ca03ab71199da Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:10:57 +0100 Subject: [PATCH 03/14] testing --- .github/workflows/infra.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index b5be677..a3b24d7 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -20,6 +20,9 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - run: -| + uname -a + lsb_release -a - name: Setup Python uses: actions/setup-python@v4 with: -- 2.40.1 From fe43f55a4868e759cde1e64cdbd9dab8cbf4018b Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:16:13 +0100 Subject: [PATCH 04/14] uhhh --- .github/workflows/infra.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index a3b24d7..327be7b 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -20,7 +20,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - run: -| + - run: | uname -a lsb_release -a - name: Setup Python @@ -29,7 +29,7 @@ jobs: python-version: ">=3.11" - name: Install dependencies - run: -| + run: | python3 -m venv venv source venv/bin/activate pip3 install -r requirements.txt @@ -42,7 +42,7 @@ jobs: files: infra/**-playbook.yaml - name: Check modified playbooks - run: -| + run: | for file in ${{ steps.changed-playbooks.outputs.all_changed_files }}; do ansible --inventory ./inventory --check "$file" done -- 2.40.1 From 6a83fdf3790e5f6033b408672e7f5d59713a7de0 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:30:10 +0100 Subject: [PATCH 05/14] fix? --- .github/workflows/infra.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 327be7b..1a9b7d9 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -21,8 +21,7 @@ jobs: uses: actions/checkout@v3 - run: | - uname -a - lsb_release -a + apt install lsb-release - name: Setup Python uses: actions/setup-python@v4 with: -- 2.40.1 From 47c06b02f9e4347b3b733f70bbdd48dc0faae4e0 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:41:34 +0100 Subject: [PATCH 06/14] remove install lsb_release --- .github/workflows/infra.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 1a9b7d9..648bca8 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -20,8 +20,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - run: | - apt install lsb-release - name: Setup Python uses: actions/setup-python@v4 with: -- 2.40.1 From f9b321367bc8a007398ac22ce2f0b7adabb702b9 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 00:45:24 +0100 Subject: [PATCH 07/14] trigger ci --- .github/workflows/infra.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 648bca8..25206d6 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -23,7 +23,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: ">=3.11" + python-version: "3.11" - name: Install dependencies run: | -- 2.40.1 From d143ffc123f2d3df4ed54cb4c9f8ce63e4f7a321 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 01:30:44 +0100 Subject: [PATCH 08/14] don't use venv --- .github/workflows/infra.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 25206d6..37f3ad0 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -27,8 +27,6 @@ jobs: - name: Install dependencies run: | - python3 -m venv venv - source venv/bin/activate pip3 install -r requirements.txt ansible-galaxy collection install community.general -- 2.40.1 From 7b7f9f5999f9761aba2a002ce9a67dc9ac4bcbac Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 01:44:10 +0100 Subject: [PATCH 09/14] idek --- .github/workflows/infra.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 37f3ad0..4b28db4 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -34,6 +34,7 @@ jobs: id: changed-playbooks uses: tj-actions/changed-files@v38 with: + since_last_remote_commit: "true" files: infra/**-playbook.yaml - name: Check modified playbooks -- 2.40.1 From e9559c939ab8752957eceec7cb6762c96993c54f Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 01:56:06 +0100 Subject: [PATCH 10/14] fix checkout? --- .github/workflows/infra.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 4b28db4..9c1f097 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -19,6 +19,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 2 - name: Setup Python uses: actions/setup-python@v4 -- 2.40.1 From f3c68d9ecbd26d8a39d346b08b9f03fd1b84cb76 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:11:53 +0100 Subject: [PATCH 11/14] testing stuff --- .github/workflows/infra.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 9c1f097..86aef50 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -11,6 +11,7 @@ on: paths: - infra/**-playbook.yaml - .github/workflows/infra.yaml + fork: jobs: check: @@ -19,8 +20,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - fetch-depth: 2 + + - run: | + echo ${{ github.event.pull_request.commits }} + echo ${{ github.event.pusher }} + echo ${{ github.event.forkee }} - name: Setup Python uses: actions/setup-python@v4 @@ -29,8 +33,8 @@ jobs: - name: Install dependencies run: | - pip3 install -r requirements.txt - ansible-galaxy collection install community.general + pip3 install -r requirements.txt ${{ github.event.pull_request.base }} + ansible-galaxy collection install community.general ${{ github.event.pull_request.merge_commit_sha }} - name: Get changed playbooks id: changed-playbooks -- 2.40.1 From d17f76ba6dcad4a33c637c50d08d54b283e294da Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:12:29 +0100 Subject: [PATCH 12/14] checking more stuff --- .github/workflows/infra.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 86aef50..3c20a3b 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -22,9 +22,9 @@ jobs: uses: actions/checkout@v3 - run: | - echo ${{ github.event.pull_request.commits }} - echo ${{ github.event.pusher }} - echo ${{ github.event.forkee }} + echo !${{ github.event.pull_request.commits }} + echo !${{ github.event.pusher }} + echo !${{ github.event.forkee }} - name: Setup Python uses: actions/setup-python@v4 -- 2.40.1 From 6e1217c9e8edbc53bb86ff2f7ed3c350890e63fd Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:13:40 +0100 Subject: [PATCH 13/14] maybe --- .github/workflows/infra.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 3c20a3b..7063770 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v3 - run: | - echo !${{ github.event.pull_request.commits }} + echo !${{ github.event.pull_request }} echo !${{ github.event.pusher }} echo !${{ github.event.forkee }} @@ -33,8 +33,8 @@ jobs: - name: Install dependencies run: | - pip3 install -r requirements.txt ${{ github.event.pull_request.base }} - ansible-galaxy collection install community.general ${{ github.event.pull_request.merge_commit_sha }} + pip3 install -r requirements.txt + ansible-galaxy collection install community.general - name: Get changed playbooks id: changed-playbooks -- 2.40.1 From c8c624e82b362cb991f8af30850f432f7b92a473 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Tue, 29 Aug 2023 02:14:45 +0100 Subject: [PATCH 14/14] more checking --- .github/workflows/infra.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/infra.yaml b/.github/workflows/infra.yaml index 7063770..aa327d0 100644 --- a/.github/workflows/infra.yaml +++ b/.github/workflows/infra.yaml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v3 - run: | - echo !${{ github.event.pull_request }} + echo !${{ github.event.pull_request.base.repo }} !${{ github.event.pull_request.base.sha }} echo !${{ github.event.pusher }} echo !${{ github.event.forkee }} -- 2.40.1