From 7efccce3eb549c2a11bd9a8c0ef46da7cc1d03c9 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 17:05:16 +0000 Subject: [PATCH 01/36] Adding devcontainer up unit test --- .devcontainer/devcontainer.json | 23 +++++++++++++++++++ .github/workflows/run-tests.yaml | 9 ++++++++ .github/workflows/test-devcontainer-up.yaml | 17 ++++++++++++++ .../devcontainer-exec-script/action.yaml | 19 +++++++++++++++ .../test-devcontainer-execute-script.sh | 1 + 5 files changed, 69 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/workflows/test-devcontainer-up.yaml create mode 100644 composite-actions/devcontainer-exec-script/action.yaml create mode 100644 test-scripts/test-devcontainer-execute-script.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..a524d4a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,23 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/base:bullseye", + "features": { + "ghcr.io/devcontainers/features/azure-cli:1": {}, + "ghcr.io/devcontainers-extra/features/devcontainers-cli:1": {} + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 8eba109..166099a 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -10,6 +10,15 @@ on: - '**' jobs: + test-devcontainer-up-amd64: + permissions: + contents: read + packages: read + + uses: ./.github/workflows/test-devcontainer-up.yaml + with: + agent: ubuntu-latest + test-get-agent-details-amd64: permissions: contents: read diff --git a/.github/workflows/test-devcontainer-up.yaml b/.github/workflows/test-devcontainer-up.yaml new file mode 100644 index 0000000..6f6f2ba --- /dev/null +++ b/.github/workflows/test-devcontainer-up.yaml @@ -0,0 +1,17 @@ +name: test devcontainer up +on: + workflow_call: + inputs: + agent: + description: 'The agent to run the job on' + required: true + type: string + +jobs: + test-get-agent-details: + runs-on: ${{ inputs.agent }} + + steps: + - uses: actions/checkout@v2 + + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-up@devcontainer-up-latest \ No newline at end of file diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml new file mode 100644 index 0000000..cb9c8a7 --- /dev/null +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -0,0 +1,19 @@ + +name: 'exec-script-dev-container' +description: 'this command runs a script inside the devcontainer' +inputs: + workspace-folder: + description: 'The workspace folder' + default: "${PWD}" + container-name: + description: 'The name of the container' + default: "devcontainer" + script-path: + description: 'The path to the script to run' +runs: + using: 'composite' + steps: + - name: Run script inside devcontainer + shell: bash + run: | + docker exec ${{ inputs.container-name }} /bin/bash -c "${{ inputs.script-path }}" \ No newline at end of file diff --git a/test-scripts/test-devcontainer-execute-script.sh b/test-scripts/test-devcontainer-execute-script.sh new file mode 100644 index 0000000..c671eae --- /dev/null +++ b/test-scripts/test-devcontainer-execute-script.sh @@ -0,0 +1 @@ +echo "This output is expected to be printed to the console successfully." \ No newline at end of file From b89cab385d211c901d50a2a7f54baa8c60bbae59 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 13:08:49 -0400 Subject: [PATCH 02/36] Adding changes --- .github/workflows/test-devcontainer-up.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-devcontainer-up.yaml b/.github/workflows/test-devcontainer-up.yaml index 6f6f2ba..a88c4cf 100644 --- a/.github/workflows/test-devcontainer-up.yaml +++ b/.github/workflows/test-devcontainer-up.yaml @@ -14,4 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer@install-devcontainer-latest + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-up@devcontainer-up-latest \ No newline at end of file From 4bf35a1ce0142bc8a92bbb515ca2c578b641d92f Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 13:10:15 -0400 Subject: [PATCH 03/36] Adding installation --- .github/workflows/test-devcontainer-up.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-devcontainer-up.yaml b/.github/workflows/test-devcontainer-up.yaml index a88c4cf..971309d 100644 --- a/.github/workflows/test-devcontainer-up.yaml +++ b/.github/workflows/test-devcontainer-up.yaml @@ -14,6 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer@install-devcontainer-latest + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer@main - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-up@devcontainer-up-latest \ No newline at end of file From b1bc5bf42826c2564fcba3dfd43d34322f1d9dcf Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 13:29:43 -0400 Subject: [PATCH 04/36] Updating reference --- .github/workflows/test-devcontainer-up.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-devcontainer-up.yaml b/.github/workflows/test-devcontainer-up.yaml index 971309d..a88c4cf 100644 --- a/.github/workflows/test-devcontainer-up.yaml +++ b/.github/workflows/test-devcontainer-up.yaml @@ -14,6 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer@main + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer@install-devcontainer-latest - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-up@devcontainer-up-latest \ No newline at end of file From 3f964bfae29a91672594fcc5f227694a4091323e Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 13:40:05 -0400 Subject: [PATCH 05/36] Adding main --- .github/workflows/test-devcontainer-up.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-devcontainer-up.yaml b/.github/workflows/test-devcontainer-up.yaml index a88c4cf..971309d 100644 --- a/.github/workflows/test-devcontainer-up.yaml +++ b/.github/workflows/test-devcontainer-up.yaml @@ -14,6 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer@install-devcontainer-latest + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer@main - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-up@devcontainer-up-latest \ No newline at end of file From 5d8becec33612d77261130259d7563d0c1aab34e Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 14:49:38 -0400 Subject: [PATCH 06/36] Fixing action name --- .github/workflows/test-devcontainer-up.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-devcontainer-up.yaml b/.github/workflows/test-devcontainer-up.yaml index 971309d..b73847d 100644 --- a/.github/workflows/test-devcontainer-up.yaml +++ b/.github/workflows/test-devcontainer-up.yaml @@ -14,6 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer@main + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer-cli@main - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-up@devcontainer-up-latest \ No newline at end of file From 0494c7e0ae4e7d64fe5ba2a9dede5c8d04c52c02 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 14:51:01 -0400 Subject: [PATCH 07/36] Fixing job name --- .github/workflows/test-devcontainer-up.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-devcontainer-up.yaml b/.github/workflows/test-devcontainer-up.yaml index b73847d..20f124d 100644 --- a/.github/workflows/test-devcontainer-up.yaml +++ b/.github/workflows/test-devcontainer-up.yaml @@ -8,7 +8,7 @@ on: type: string jobs: - test-get-agent-details: + test-dev-container-up: runs-on: ${{ inputs.agent }} steps: From 47309432d99fef207937ad74b9b1bd4b7417caa4 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 14:54:09 -0400 Subject: [PATCH 08/36] Updating for tag --- .github/workflows/test-devcontainer-up.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-devcontainer-up.yaml b/.github/workflows/test-devcontainer-up.yaml index 20f124d..d4e22b4 100644 --- a/.github/workflows/test-devcontainer-up.yaml +++ b/.github/workflows/test-devcontainer-up.yaml @@ -14,6 +14,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer-cli@main + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer-cli@install-devcontainer-cli-latest - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-up@devcontainer-up-latest \ No newline at end of file From 6024e1b3daf729c6d0267ebe1c64bf0debd57412 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 15:09:29 -0400 Subject: [PATCH 09/36] Adding devcontainer exec test --- .../test-devcontainer-exec-script.yaml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/test-devcontainer-exec-script.yaml diff --git a/.github/workflows/test-devcontainer-exec-script.yaml b/.github/workflows/test-devcontainer-exec-script.yaml new file mode 100644 index 0000000..f1d08ee --- /dev/null +++ b/.github/workflows/test-devcontainer-exec-script.yaml @@ -0,0 +1,26 @@ +name: test devcontainer up +on: + workflow_call: + inputs: + agent: + description: 'The agent to run the job on' + required: true + type: string + +jobs: + test-dev-container-up: + runs-on: ${{ inputs.agent }} + + steps: + - uses: actions/checkout@v2 + + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/install-devcontainer-cli@install-devcontainer-cli-latest + + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-up@devcontainer-up-latest + + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-exec-script@21-devcontainer-actions + with: + workspace-folder: ${{ github.workspace }} + container-name: devcontainer + script-path: "./test-scripts/test-devcontainer-execute-script.sh" + \ No newline at end of file From c6f10b1f8669240706a598fe70b3c836df95ca23 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 15:10:28 -0400 Subject: [PATCH 10/36] adding to test runner --- .github/workflows/run-tests.yaml | 9 +++++++++ .github/workflows/test-devcontainer-exec-script.yaml | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 166099a..b974663 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -10,6 +10,15 @@ on: - '**' jobs: + test-devcontainer-exec-script-amd64: + permissions: + contents: read + packages: read + + uses: ./.github/workflows/test-devcontainer-exec-script.yaml + with: + agent: ubuntu-latest + test-devcontainer-up-amd64: permissions: contents: read diff --git a/.github/workflows/test-devcontainer-exec-script.yaml b/.github/workflows/test-devcontainer-exec-script.yaml index f1d08ee..bf7c672 100644 --- a/.github/workflows/test-devcontainer-exec-script.yaml +++ b/.github/workflows/test-devcontainer-exec-script.yaml @@ -1,4 +1,4 @@ -name: test devcontainer up +name: test devcontainer exec script on: workflow_call: inputs: @@ -8,7 +8,7 @@ on: type: string jobs: - test-dev-container-up: + test-dev-container-exec-script: runs-on: ${{ inputs.agent }} steps: From 3afa02907fc2c2e2adaa3015cc8a405d6757cc17 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 15:13:05 -0400 Subject: [PATCH 11/36] Adding new container name --- .devcontainer/devcontainer.json | 2 +- .github/workflows/test-devcontainer-exec-script.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a524d4a..a73abb9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/debian { - "name": "Debian", + "name": "bicep-environment-templates", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/base:bullseye", "features": { diff --git a/.github/workflows/test-devcontainer-exec-script.yaml b/.github/workflows/test-devcontainer-exec-script.yaml index bf7c672..6e84532 100644 --- a/.github/workflows/test-devcontainer-exec-script.yaml +++ b/.github/workflows/test-devcontainer-exec-script.yaml @@ -21,6 +21,6 @@ jobs: - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-exec-script@21-devcontainer-actions with: workspace-folder: ${{ github.workspace }} - container-name: devcontainer + container-name: bicep-environment-templates script-path: "./test-scripts/test-devcontainer-execute-script.sh" \ No newline at end of file From 9ffb4106b4ea6fa6538003f9964202143f3bc142 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 15:16:27 -0400 Subject: [PATCH 12/36] Adding validating step --- .github/workflows/test-devcontainer-exec-script.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test-devcontainer-exec-script.yaml b/.github/workflows/test-devcontainer-exec-script.yaml index 6e84532..b9c15ca 100644 --- a/.github/workflows/test-devcontainer-exec-script.yaml +++ b/.github/workflows/test-devcontainer-exec-script.yaml @@ -18,6 +18,15 @@ jobs: - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-up@devcontainer-up-latest + - name: Validate Container + shell: bash + run: | + echo "Validating the container is running" + echo "Container Name: bicep-environment-templates" + echo "Running Containers:" + echo "--------------------------------" + docker container ls + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-exec-script@21-devcontainer-actions with: workspace-folder: ${{ github.workspace }} From 8458a5fe0f73926620bcfd2f7ef412d9b0d98532 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 15:30:28 -0400 Subject: [PATCH 13/36] Updating for container name --- .github/workflows/test-devcontainer-exec-script.yaml | 2 +- composite-actions/devcontainer-up/action.yaml | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-devcontainer-exec-script.yaml b/.github/workflows/test-devcontainer-exec-script.yaml index b9c15ca..c36dc1d 100644 --- a/.github/workflows/test-devcontainer-exec-script.yaml +++ b/.github/workflows/test-devcontainer-exec-script.yaml @@ -30,6 +30,6 @@ jobs: - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-exec-script@21-devcontainer-actions with: workspace-folder: ${{ github.workspace }} - container-name: bicep-environment-templates + container-name: devcontainer script-path: "./test-scripts/test-devcontainer-execute-script.sh" \ No newline at end of file diff --git a/composite-actions/devcontainer-up/action.yaml b/composite-actions/devcontainer-up/action.yaml index 6e5c521..4910ebf 100644 --- a/composite-actions/devcontainer-up/action.yaml +++ b/composite-actions/devcontainer-up/action.yaml @@ -4,6 +4,9 @@ inputs: workspace-folder: description: 'The workspace folder' default: "${PWD}" + container-name: + description: 'The name of the container' + default: "devcontainer" runs: using: 'composite' steps: @@ -18,5 +21,6 @@ runs: --remove-existing-container \ --mount type=volume,source=vscode,target=/vscode,external=true \ --update-remote-user-uid-default on \ - --mount-workspace-git-root true + --mount-workspace-git-root true \ + --container-name ${{ inputs.container-name }} \ echo $? \ No newline at end of file From cbaf9cd2dcb02aa53b113110d7f198b3e0d67edb Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 15:40:39 -0400 Subject: [PATCH 14/36] Adding name --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a73abb9..86d279d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,13 +1,14 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/debian { - "name": "bicep-environment-templates", + "name": "devcontainer", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/base:bullseye", "features": { "ghcr.io/devcontainers/features/azure-cli:1": {}, "ghcr.io/devcontainers-extra/features/devcontainers-cli:1": {} } + // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, From ebc5f9e6d04e7a82a49b8a82ffb2d627a6224b7d Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 15:49:37 -0400 Subject: [PATCH 15/36] Updating Validate step --- .github/workflows/test-devcontainer-exec-script.yaml | 2 +- composite-actions/install-devcontainer-cli/action.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-devcontainer-exec-script.yaml b/.github/workflows/test-devcontainer-exec-script.yaml index c36dc1d..3d3bbdb 100644 --- a/.github/workflows/test-devcontainer-exec-script.yaml +++ b/.github/workflows/test-devcontainer-exec-script.yaml @@ -25,7 +25,7 @@ jobs: echo "Container Name: bicep-environment-templates" echo "Running Containers:" echo "--------------------------------" - docker container ls + docker ps --format "{{.Names}}" - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-exec-script@21-devcontainer-actions with: diff --git a/composite-actions/install-devcontainer-cli/action.yaml b/composite-actions/install-devcontainer-cli/action.yaml index 24e0a12..cdf9f28 100644 --- a/composite-actions/install-devcontainer-cli/action.yaml +++ b/composite-actions/install-devcontainer-cli/action.yaml @@ -13,7 +13,7 @@ runs: if [[ "$ARCH" == "x86_64" ]]; then echo "amd64 architecture detected" echo "Installing npm.." - echo "Runnning 'npm install -g n'..." + echo "Running 'npm install -g n'..." sudo npm install -g n echo "Runnning 'npm install -g @devcontainers/cli'..." sudo npm install -g @devcontainers/cli From 7e06ad999f21a348574baa737db27614465551f2 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 15:53:37 -0400 Subject: [PATCH 16/36] Flipping to devcontainer cli for execution --- composite-actions/devcontainer-exec-script/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index cb9c8a7..2e6377f 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -16,4 +16,4 @@ runs: - name: Run script inside devcontainer shell: bash run: | - docker exec ${{ inputs.container-name }} /bin/bash -c "${{ inputs.script-path }}" \ No newline at end of file + devcontainer exec ${{ inputs.container-name }} /bin/bash -c "${{ inputs.script-path }}" \ No newline at end of file From 5aff93e4e136695d9b16d82bf815a515105814c8 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 15:57:10 -0400 Subject: [PATCH 17/36] Fixing command --- composite-actions/devcontainer-exec-script/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index 2e6377f..7472fc2 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -16,4 +16,4 @@ runs: - name: Run script inside devcontainer shell: bash run: | - devcontainer exec ${{ inputs.container-name }} /bin/bash -c "${{ inputs.script-path }}" \ No newline at end of file + devcontainer exec ${{ inputs.container-name }} bash -c "${{ inputs.script-path }}" \ No newline at end of file From de3be89205874de272241ec4944e363075115cfe Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 16:01:37 -0400 Subject: [PATCH 18/36] Adding workspace folder --- composite-actions/devcontainer-exec-script/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index 7472fc2..0709790 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -16,4 +16,4 @@ runs: - name: Run script inside devcontainer shell: bash run: | - devcontainer exec ${{ inputs.container-name }} bash -c "${{ inputs.script-path }}" \ No newline at end of file + devcontainer exec ${{ inputs.container-name }} bash -c "${{ inputs.script-path }}" --workspace-folder ${{ inputs.workspace-folder }} \ No newline at end of file From 017c6cf021210315dbb628934d1080d2561afae4 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 16:04:29 -0400 Subject: [PATCH 19/36] Rearrange items --- composite-actions/devcontainer-exec-script/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index 0709790..6c6d3cb 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -16,4 +16,4 @@ runs: - name: Run script inside devcontainer shell: bash run: | - devcontainer exec ${{ inputs.container-name }} bash -c "${{ inputs.script-path }}" --workspace-folder ${{ inputs.workspace-folder }} \ No newline at end of file + devcontainer exec --workspace-folder ${{ inputs.workspace-folder }} ${{ inputs.container-name }} bash -c "${{ inputs.script-path }}" \ No newline at end of file From acdfb0c227b3f9a558d2888580dab8fa9489ef7f Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Fri, 14 Mar 2025 16:07:30 -0400 Subject: [PATCH 20/36] Updating signature --- composite-actions/devcontainer-exec-script/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index 6c6d3cb..8485fd8 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -16,4 +16,4 @@ runs: - name: Run script inside devcontainer shell: bash run: | - devcontainer exec --workspace-folder ${{ inputs.workspace-folder }} ${{ inputs.container-name }} bash -c "${{ inputs.script-path }}" \ No newline at end of file + devcontainer exec --workspace-folder ${{ inputs.workspace-folder }} "${{ inputs.script-path }}" \ No newline at end of file From de2114636551f154b515b08184d37735604f58e2 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Mon, 17 Mar 2025 14:21:25 -0400 Subject: [PATCH 21/36] Restructing command --- composite-actions/devcontainer-exec-script/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index 8485fd8..8dfd8a0 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -16,4 +16,4 @@ runs: - name: Run script inside devcontainer shell: bash run: | - devcontainer exec --workspace-folder ${{ inputs.workspace-folder }} "${{ inputs.script-path }}" \ No newline at end of file + devcontainer exec "${{ inputs.script-path }}" --workspace-folder ${{ inputs.workspace-folder }} \ No newline at end of file From 234c87a09f6b72c996ffebcb51d48fc9c96a838f Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 18 Mar 2025 16:32:01 -0400 Subject: [PATCH 22/36] Adding output steps --- composite-actions/devcontainer-exec-script/action.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index 8dfd8a0..09ee873 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -16,4 +16,8 @@ runs: - name: Run script inside devcontainer shell: bash run: | + echo "Script path: ${{ inputs.script-path }}" + echo "Container name: ${{ inputs.container-name }}" + echo "Workspace folder: ${{ inputs.workspace-folder }}" + echo "Running script inside devcontainer..." devcontainer exec "${{ inputs.script-path }}" --workspace-folder ${{ inputs.workspace-folder }} \ No newline at end of file From 82a34eba939471ed983796e017d0e54945a59c9f Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 18 Mar 2025 16:38:57 -0400 Subject: [PATCH 23/36] Updating for double quotes --- composite-actions/devcontainer-exec-script/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index 09ee873..cc6b337 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -20,4 +20,4 @@ runs: echo "Container name: ${{ inputs.container-name }}" echo "Workspace folder: ${{ inputs.workspace-folder }}" echo "Running script inside devcontainer..." - devcontainer exec "${{ inputs.script-path }}" --workspace-folder ${{ inputs.workspace-folder }} \ No newline at end of file + devcontainer exec "${{ inputs.script-path }}" --workspace-folder "${{ inputs.workspace-folder }}"" \ No newline at end of file From 0f8b1978cf0e3b2111bf5e56d376c9022a5cd323 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 18 Mar 2025 16:41:28 -0400 Subject: [PATCH 24/36] Updating to remove extra quote --- composite-actions/devcontainer-exec-script/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index cc6b337..019d62f 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -20,4 +20,4 @@ runs: echo "Container name: ${{ inputs.container-name }}" echo "Workspace folder: ${{ inputs.workspace-folder }}" echo "Running script inside devcontainer..." - devcontainer exec "${{ inputs.script-path }}" --workspace-folder "${{ inputs.workspace-folder }}"" \ No newline at end of file + devcontainer exec "${{ inputs.script-path }}" --workspace-folder "${{ inputs.workspace-folder }}" \ No newline at end of file From db3d53bc8abdb3dfbdd4dc5adc5583a83633a937 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 18 Mar 2025 16:44:11 -0400 Subject: [PATCH 25/36] Adding logic --- composite-actions/devcontainer-exec-script/action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index 019d62f..39f99b4 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -20,4 +20,5 @@ runs: echo "Container name: ${{ inputs.container-name }}" echo "Workspace folder: ${{ inputs.workspace-folder }}" echo "Running script inside devcontainer..." + echo "devcontainer exec \"${{ inputs.script-path }}\" --workspace-folder \"${{ inputs.workspace-folder }}\"" devcontainer exec "${{ inputs.script-path }}" --workspace-folder "${{ inputs.workspace-folder }}" \ No newline at end of file From 7641b0b52781e2b6380107a5630b47b4baf129e2 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 18 Mar 2025 17:11:08 -0400 Subject: [PATCH 26/36] Updating reference --- .devcontainer/devcontainer.json | 1 - composite-actions/devcontainer-exec-script/action.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 86d279d..e7b8817 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,6 @@ "ghcr.io/devcontainers/features/azure-cli:1": {}, "ghcr.io/devcontainers-extra/features/devcontainers-cli:1": {} } - // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, diff --git a/composite-actions/devcontainer-exec-script/action.yaml b/composite-actions/devcontainer-exec-script/action.yaml index 39f99b4..18a7c5e 100644 --- a/composite-actions/devcontainer-exec-script/action.yaml +++ b/composite-actions/devcontainer-exec-script/action.yaml @@ -21,4 +21,4 @@ runs: echo "Workspace folder: ${{ inputs.workspace-folder }}" echo "Running script inside devcontainer..." echo "devcontainer exec \"${{ inputs.script-path }}\" --workspace-folder \"${{ inputs.workspace-folder }}\"" - devcontainer exec "${{ inputs.script-path }}" --workspace-folder "${{ inputs.workspace-folder }}" \ No newline at end of file + devcontainer exec --workspace-folder . "${{ inputs.script-path }}" \ No newline at end of file From b09cafaacd3ac57b70e6995531ffa379fd9c3cb1 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 18 Mar 2025 17:17:31 -0400 Subject: [PATCH 27/36] Updating script --- test-scripts/test-devcontainer-execute-script.sh | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 test-scripts/test-devcontainer-execute-script.sh diff --git a/test-scripts/test-devcontainer-execute-script.sh b/test-scripts/test-devcontainer-execute-script.sh old mode 100644 new mode 100755 index c671eae..6e4fa37 --- a/test-scripts/test-devcontainer-execute-script.sh +++ b/test-scripts/test-devcontainer-execute-script.sh @@ -1 +1,2 @@ +#!/bin/bash echo "This output is expected to be printed to the console successfully." \ No newline at end of file From 3f6c89b5475a502f48c2dbd3377955ae0b92b731 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 18 Mar 2025 17:22:05 -0400 Subject: [PATCH 28/36] Fixing reference --- .github/workflows/test-devcontainer-exec-script.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-devcontainer-exec-script.yaml b/.github/workflows/test-devcontainer-exec-script.yaml index 3d3bbdb..5e8a4a0 100644 --- a/.github/workflows/test-devcontainer-exec-script.yaml +++ b/.github/workflows/test-devcontainer-exec-script.yaml @@ -27,7 +27,7 @@ jobs: echo "--------------------------------" docker ps --format "{{.Names}}" - - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-exec-script@21-devcontainer-actions + - uses: mack-bytes-government/bicep-environment-templates/composite-actions/devcontainer-exec-script@devcontainer-exec-script-latest with: workspace-folder: ${{ github.workspace }} container-name: devcontainer From 4a447011515b771d942d03205fa2700d79a2a13b Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 8 Apr 2025 16:12:27 -0400 Subject: [PATCH 29/36] Updating with demo --- bicep-sample/sample-app-service.bicep | 21 ++++++++++++++ bicep-sample/sample-deployment.bicep | 40 +++++++++++++++++++++++++++ bicep-sample/sample-storage.bicep | 12 ++++++++ 3 files changed, 73 insertions(+) create mode 100644 bicep-sample/sample-app-service.bicep create mode 100644 bicep-sample/sample-deployment.bicep create mode 100644 bicep-sample/sample-storage.bicep diff --git a/bicep-sample/sample-app-service.bicep b/bicep-sample/sample-app-service.bicep new file mode 100644 index 0000000..949883d --- /dev/null +++ b/bicep-sample/sample-app-service.bicep @@ -0,0 +1,21 @@ +param prefix string +param location string = 'usgovvirginia' +param appServicePlanSku string = 'P1v2' + +resource appService 'Microsoft.Web/sites@2022-03-01' = { + name: '${prefix}-app' + location: location + properties: { + serverFarmId: appServicePlan.id + } +} + +resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = { + name: '${prefix}-app-plan' + location: location + sku: { + name: appServicePlanSku + tier: 'PremiumV2' + } + kind: 'app' +} diff --git a/bicep-sample/sample-deployment.bicep b/bicep-sample/sample-deployment.bicep new file mode 100644 index 0000000..2bc92e6 --- /dev/null +++ b/bicep-sample/sample-deployment.bicep @@ -0,0 +1,40 @@ +targetScope = 'subscription' +@description('Prefix for the resource names') +param prefix string + +@description('Location for the resource group') +param location string = 'usgovvirginia' + +@description('SKU for the App Service Plan') +param appServicePlanSku string = 'P1v2' + +@description('SKU for the Storage Account') +param storageSku string = 'Standard_LRS' + +// Resource Group +resource resourceGroup 'Microsoft.Resources/resourceGroups@2024-11-01' = { + name: '${prefix}-rg' + location: location +} + +module appServiceModule 'sample-app-service.bicep' = { + name: 'appServiceModule' + scope: resourceGroup + params: { + prefix: prefix + location: location + appServicePlanSku: appServicePlanSku + } +} +module storageModule 'sample-storage.bicep' = { + name: 'storageModule' + scope: resourceGroup + params: { + prefix: prefix + location: location + storageSku: storageSku + } +} + +// Output resource IDs +output resourceGroupId string = resourceGroup.id diff --git a/bicep-sample/sample-storage.bicep b/bicep-sample/sample-storage.bicep new file mode 100644 index 0000000..bf0356e --- /dev/null +++ b/bicep-sample/sample-storage.bicep @@ -0,0 +1,12 @@ +param prefix string +param location string = 'usgovvirginia' +param storageSku string = 'Standard_LRS' + +resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = { + name: '${prefix}stg' + location: location + sku: { + name: storageSku + } + kind: 'StorageV2' +} From 1a504a68f6ede891e8f818b9d2dcb8a51163d538 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Thu, 5 Jun 2025 11:27:15 -0400 Subject: [PATCH 30/36] Adding tasks and extensions --- .vscode/extensions.json | 5 +++++ .vscode/tasks.json | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..d7a0217 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "hashicorp.hcl" + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..d4bfc0a --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,23 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Install Packer", + "type": "shell", + "command": "./scripts/install-packer.sh", + "args": [], + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "shared", + "close": false + }, + "problemMatcher": [] + } + ] +} \ No newline at end of file From 883ebbb5289d0fd4d0721c4f8d662070f86f3e2f Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Thu, 5 Jun 2025 11:27:43 -0400 Subject: [PATCH 31/36] Adding install packer script --- scripts/install-packer.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 scripts/install-packer.sh diff --git a/scripts/install-packer.sh b/scripts/install-packer.sh new file mode 100644 index 0000000..92eef2b --- /dev/null +++ b/scripts/install-packer.sh @@ -0,0 +1,3 @@ +curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - +echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list +sudo apt-get update && sudo apt-get install packer \ No newline at end of file From 7303719368f8ca0e98ea31bf755a1d30d4f040b0 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Thu, 5 Jun 2025 11:28:04 -0400 Subject: [PATCH 32/36] Adding linux vm packer images for kubernetes jumpbox --- vm-images/kubernetes-linux-jumpbox.pkr.hcl | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 vm-images/kubernetes-linux-jumpbox.pkr.hcl diff --git a/vm-images/kubernetes-linux-jumpbox.pkr.hcl b/vm-images/kubernetes-linux-jumpbox.pkr.hcl new file mode 100644 index 0000000..7a0f128 --- /dev/null +++ b/vm-images/kubernetes-linux-jumpbox.pkr.hcl @@ -0,0 +1,126 @@ +variable "subscription_id" { + type = string + default = "" + description = "Azure Subscription ID" +} + +variable "location" { + type = string + default = "usgovvirginia" + description = "Azure region for the image" +} + +packer { + required_plugins { + azure = { + version = ">= 1.0.0" + source = "github.com/hashicorp/azure" + } + } +} + +source "azure-arm" "ubuntu2404" { + subscription_id = var.subscription_id + cloud_environment_name = "AzureUSGovernmentCloud" + location = var.location + + managed_image_resource_group_name = "packer-vm-images" + managed_image_name = "ubuntu2404-aks-linux-jumpbox-image" + + vm_size = "Standard_DS1_v2" + os_type = "Linux" + image_publisher = "Canonical" + image_offer = "ubuntu-24_04-lts" + image_sku = "server" + image_version = "latest" + + azure_tags = { + environment = "image-library" + } + + use_azure_cli_auth = true +} + +build { + sources = ["source.azure-arm.ubuntu2404"] + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + inline = [ + "echo 'Running the initial setup upgrade...'", + "sudo apt-get update", + "sudo apt-get upgrade -y" + ] + } + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + inline = [ + "echo 'Installing kubectl...'", + "curl -LO \"https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl\"", + "sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl", + "kubectl version --client" + ] + } + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + inline = [ + "echo 'Install Azure CLI...'", + "curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash" + ] + } + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + inline = [ + "echo 'Installing Helm...'", + "curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3", + "chmod 700 get_helm.sh", + "./get_helm.sh" + ] + } + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + inline = [ + "echo 'Installing k9s...'", + "wget https://github.com/derailed/k9s/releases/download/v0.50.6/k9s_linux_amd64.deb", + "sudo apt install ./k9s_linux_amd64.deb", + "k9s version", + "rm k9s_linux_amd64.deb" + ] + } + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + inline = [ + "echo 'Installing Terraform...'", + "wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg", + "echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/hashicorp.list", + "sudo apt update && sudo apt install terraform" + ] + } + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + inline = [ + "echo 'Installing RegClient...'", + "curl -L https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64 >regctl", + "chmod 755 regctl" + ] + } + + provisioner "shell" { + environment_vars = ["DEBIAN_FRONTEND=noninteractive"] + inline = [ + "echo 'Installing Docker...'", + "sudo apt-get install ca-certificates curl", + "sudo install -m 0755 -d /etc/apt/keyrings", + "sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc", + "sudo chmod a+r /etc/apt/keyrings/docker.asc", + "echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable\" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null", + "sudo apt-get update" + ] + } +} \ No newline at end of file From d402fdb401f2fde1660ea0dbaa00d262113357f8 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 1 Jul 2025 11:54:36 -0400 Subject: [PATCH 33/36] Updating readme --- README.md | 1 + developer-scripts/build-packer-image.sh | 0 2 files changed, 1 insertion(+) create mode 100644 developer-scripts/build-packer-image.sh diff --git a/README.md b/README.md index 624a4e3..211f7dd 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ The key elements in this repo are: - **Bicep Modules:** These bicep modules provide "lego bricks" for assembling your infrastructure-as-code" deployments and are built to meet the specification of Government customers and impact levels. - **Developer Scripts:** These scripts are designed to include common operations that are designed to provide "easy-buttons" to prevent having to lookup what each of these steps is, and how they work. - **Github Composite Actions:** These are composite actions designed specifically to be atomic and reusable in a variety of situations. The intention being that these are common steps to prevent technical debt, improve quality, and increase stability by leveraging a single code instance. +- **Packer VM Configuration:** These are packer images for specific virtual machines that are designed to support specific use-cases. ## Bicep Modules diff --git a/developer-scripts/build-packer-image.sh b/developer-scripts/build-packer-image.sh new file mode 100644 index 0000000..e69de29 From e6cc3cdb72eb49cceed6e6faf388cbd2aa80c50b Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 1 Jul 2025 12:14:10 -0400 Subject: [PATCH 34/36] Updating parameters for more control --- vm-images/kubernetes-linux-jumpbox.pkr.hcl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/vm-images/kubernetes-linux-jumpbox.pkr.hcl b/vm-images/kubernetes-linux-jumpbox.pkr.hcl index 7a0f128..8c4d203 100644 --- a/vm-images/kubernetes-linux-jumpbox.pkr.hcl +++ b/vm-images/kubernetes-linux-jumpbox.pkr.hcl @@ -10,6 +10,18 @@ variable "location" { description = "Azure region for the image" } +variable "managed_images_rg_name" { + type = string + default = "packer-vm-images" + description = "Resource group name for the Packer VM images" +} + +variable "managed_image_name" { + type = string + default = "ubuntu2404-aks-linux-jumpbox-image" + description = "Name of the managed image to be created by Packer" +} + packer { required_plugins { azure = { @@ -24,8 +36,8 @@ source "azure-arm" "ubuntu2404" { cloud_environment_name = "AzureUSGovernmentCloud" location = var.location - managed_image_resource_group_name = "packer-vm-images" - managed_image_name = "ubuntu2404-aks-linux-jumpbox-image" + managed_image_resource_group_name = var.managed_images_rg_name + managed_image_name = var.managed_image_name vm_size = "Standard_DS1_v2" os_type = "Linux" From 140d849b1b5b94a259855fcb941b1dfa0ad20690 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 1 Jul 2025 12:14:22 -0400 Subject: [PATCH 35/36] Updating readme --- README.md | 45 +++++++++++++++++++++++-- developer-scripts/build-packer-image.sh | 0 2 files changed, 43 insertions(+), 2 deletions(-) delete mode 100644 developer-scripts/build-packer-image.sh diff --git a/README.md b/README.md index 211f7dd..e8c54d1 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,6 @@ DEFAULT_TAG_VALUE="" # The value of the tag. az deployment group create --resource-group $RESOURCE_GROUP_NAME --template-file ./modules/virtual-machine.bicep --parameters vm_name=$VM_NAME subnet_id=$SUBNET_ID data_science_vm_type=$MACHINE_TYPE admin_user_name=$ADMIN_USER_NAME default_tag_name=$DEFAULT_TAG_NAME default_tag_value=$DEFAULT_TAG_VALUE ``` - ## Developer Scripts For this repo there are several developer scripts designed to provide support for common operations. They are outlined below: @@ -130,4 +129,46 @@ When identifying the "@" value at the end of the line, you have 2 options: 1. You can use "@main" which will always pull the "main" branch version that is available. That does mean that you will always being using the latest, and if the parameter signature changes, it wil fail. 2. You can pin to the "latest" of that action file, by using "@__ACTION_NAME__-latest" (for example: get-agent-details-latest). This is predominantly used for testing. -3. You can pin to a specific version number, by using "@__ACTION_NAME__-__VERSION_NUMBER__" (for example: get-agent-details-1.0.0), this will pin you to a specific release. \ No newline at end of file +3. You can pin to a specific version number, by using "@__ACTION_NAME__-__VERSION_NUMBER__" (for example: get-agent-details-1.0.0), this will pin you to a specific release. + +## Packer Virtual Machine Configuration: + +This repo contains virtual machine configurations to support new environments that are created. The following are the key virtual machine configuration files in this repo: + +- **[kubernetes-linux-jumpbox.pkr.hcl](./vm-images/kubernetes-linux-jumpbox.pkr.hcl): This machine provides a jumpbox for accessing and working with kubernetes clusters. + +### Build packer vm images: + +To build a VM image in your Azure subscription using the `./vm-images/kubernetes-linux-jumpbox.pkr.hcl` file, follow these steps: + +1. **Install Packer** + Make sure you have [Packer](https://developer.hashicorp.com/packer/install) installed on your machine. You can run this script to install it or use the repo task by hitting F1. + + ```bash + bash ./scripts/install-packer.sh + ``` + +2. **Authenticate with Azure** + Ensure you are logged in to Azure CLI and have the necessary permissions: + ```bash + az cloud set --name AzureUSGovernment + az login --use-device-code + az account set --subscription "" + ``` + +3. **Validate the Packer Template** + Run the following command to validate your Packer template: + ```bash + packer validate ./vm-images/kubernetes-linux-jumpbox.pkr.hcl + ``` + +4. **Build the Image** + Execute the build command: + ```bash + packer build -var "subscription_id=" -var "location=" ./vm-images/kubernetes-linux-jumpbox.pkr.hcl + ``` + +5. **Locate the Image in Azure** + After the build completes, the image will be available in the resource group and location specified in your Packer template. + +> For more details, see the [Packer Azure Builder documentation](https://developer.hashicorp.com/packer/plugins/builders/azure). diff --git a/developer-scripts/build-packer-image.sh b/developer-scripts/build-packer-image.sh deleted file mode 100644 index e69de29..0000000 From 88b3128e19822457f08e2c589d92ebde7d0d5d18 Mon Sep 17 00:00:00 2001 From: KevinDMack Date: Tue, 1 Jul 2025 17:13:56 +0000 Subject: [PATCH 36/36] Updating for packer install --- .devcontainer/devcontainer.json | 5 ++++- scripts/install-packer.sh | 14 +++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) mode change 100644 => 100755 scripts/install-packer.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e7b8817..04ca613 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,7 +7,10 @@ "features": { "ghcr.io/devcontainers/features/azure-cli:1": {}, "ghcr.io/devcontainers-extra/features/devcontainers-cli:1": {} - } + }, + + // Run script after container is created + "postCreateCommand": "chmod +x ./scripts/install-packer.sh && ./scripts/install-packer.sh" // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, diff --git a/scripts/install-packer.sh b/scripts/install-packer.sh old mode 100644 new mode 100755 index 92eef2b..b0c8509 --- a/scripts/install-packer.sh +++ b/scripts/install-packer.sh @@ -1,3 +1,11 @@ -curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - -echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list -sudo apt-get update && sudo apt-get install packer \ No newline at end of file +#!/bin/bash +set -e + +# Download and add HashiCorp GPG key to the keyring +curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg + +# Add HashiCorp repository with proper keyring reference +echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list + +# Update package list and install Packer +sudo apt-get update && sudo apt-get install -y packer \ No newline at end of file