From 15044c8fb9e1bc63d22c44d7fbde8ea575bb9bc7 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Mon, 14 Aug 2023 01:05:21 -0500 Subject: [PATCH] Beginning vmware-iso --- .github/actions/install_packer/action.yml | 2 +- .github/workflows/test.yml | 63 ++--------------------- ansible/roles/latest/tasks/main.yml | 10 ++-- distros/nixos/supports.yml | 2 + sources/build.pkr.hcl | 7 ++- sources/vmware-iso.pkr.hcl | 28 ++++++++++ 6 files changed, 45 insertions(+), 67 deletions(-) create mode 100644 sources/vmware-iso.pkr.hcl diff --git a/.github/actions/install_packer/action.yml b/.github/actions/install_packer/action.yml index a5f7ff7..f44d82a 100644 --- a/.github/actions/install_packer/action.yml +++ b/.github/actions/install_packer/action.yml @@ -5,7 +5,7 @@ inputs: version: description: Version of Packer to install required: true - default: "1.8.0" + default: "1.9.2" pup_version: description: Version of Pup to install required: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 31fdbf3..894d77c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: - name: Run syntax check run: | set -exo pipefail - for vars in distros/*; do + for vars in $(find distros/ -name '*.pkrvars.hcl'); do if [[ "${vars}" == *.sh ]]; then "./${vars}" vars=${vars%.sh} @@ -30,34 +30,6 @@ jobs: packer validate -except=upload -var-file=${vars} sources/ done - collect: - name: Collect all Ansible-related jobs - runs-on: ubuntu-22.04 - outputs: - all: ${{ steps.zipped.outputs.scenarios }} - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - name: Collect dependencies - id: collection - uses: greg-hellings/tox-list@v1 - with: - tox-args: --ansible-driver docker --ansible-driver podman --ansible-driver containers - - id: vagrant - uses: greg-hellings/tox-list@v1 - with: - tox-args: --ansible-driver vagrant - - id: zipped - name: Zip arrays together - shell: python - run: | - import json - ubuntu = json.loads('${{ steps.collection.outputs.tox-envs }}') - macos = json.loads('${{ steps.vagrant.outputs.tox-envs }}') - ub_zip = [{'os': 'ubuntu-22.04', 'scenario': u} for u in ubuntu] - mac_zip = [{'os': 'macos-12', 'scenario': m} for m in macos] - print("::set-output name=scenarios::" + json.dumps(ub_zip + mac_zip)) - lint: name: Lint Ansible code runs-on: ubuntu-22.04 @@ -69,35 +41,6 @@ jobs: with: ansible: true - name: Run lint - run: tox -e lint_all - - build: - name: Ansible tests on roles - runs-on: ${{ matrix.scenarios.os }} - needs: - - collect - strategy: - fail-fast: false - matrix: - scenarios: "${{ fromJson(needs.collect.outputs.all) }}" - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - uses: ./.github/actions/install_packer - - name: Container setup - shell: bash - if: ${{ startsWith(matrix.scenarios.os, 'ubuntu') }} run: | - set -exo pipefail - # Enable cgroupv2 systemd stuff - sudo loginctl enable-linger 1001 - - name: Run scenario - run: | - set -ex - TOX="$(which tox)" - ${TOX} -e "${{ matrix.scenarios.scenario }}" -- --destroy=never - - name: Get possible output - if: ${{ failure() }} - run: | - set -x - cat /home/runner/.cache/molecule/init/ubuntu18/vagrant.err + yamllint -c ansible/yamllint.yml ansible .github + # TODO: Add ansible-lint run diff --git a/ansible/roles/latest/tasks/main.yml b/ansible/roles/latest/tasks/main.yml index a671215..760f548 100644 --- a/ansible/roles/latest/tasks/main.yml +++ b/ansible/roles/latest/tasks/main.yml @@ -3,11 +3,11 @@ file: "{{ item }}" with_first_found: - files: - - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml" - - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" - - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}.yml" - - "{{ role_path }}/tasks/{{ ansible_facts['os_family'] }}.yml" - - "{{ role_path }}/tasks/default.yml" + - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml" + - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml" + - "{{ role_path }}/tasks/{{ ansible_facts['distribution'] }}.yml" + - "{{ role_path }}/tasks/{{ ansible_facts['os_family'] }}.yml" + - "{{ role_path }}/tasks/default.yml" - name: Reboot, but don't care if it doesn't block: diff --git a/distros/nixos/supports.yml b/distros/nixos/supports.yml index 1469f18..2a17f09 100644 --- a/distros/nixos/supports.yml +++ b/distros/nixos/supports.yml @@ -3,3 +3,5 @@ provider: qemu - arch: x86_64 provider: virtualbox-iso +- arch: x86_64 + provider: vmware-iso diff --git a/sources/build.pkr.hcl b/sources/build.pkr.hcl index d4f2f05..773d195 100644 --- a/sources/build.pkr.hcl +++ b/sources/build.pkr.hcl @@ -12,13 +12,18 @@ packer { source = "github.com/hashicorp/vagrant" version = "~> 1" } + vmware = { + version = ">= 1.0" + source = "github.com/hashicorp/vmware" + } } } build { sources = [ "source.qemu.x86_64", - "source.virtualbox-iso.x86_64" + "source.virtualbox-iso.x86_64", + "source.vmware-iso.x86_64" ] provisioner "ansible" { diff --git a/sources/vmware-iso.pkr.hcl b/sources/vmware-iso.pkr.hcl new file mode 100644 index 0000000..c0c897a --- /dev/null +++ b/sources/vmware-iso.pkr.hcl @@ -0,0 +1,28 @@ +source "vmware-iso" "x86_64" { + iso_url = var.iso.url + iso_checksum = var.iso.checksum + output_directory = "output/vmware/${local.name}" + + boot_command = var.boot_command + shutdown_command = var.shutdown_command + boot_wait = var.boot_wait + + ssh_timeout = local.ssh.timeout + ssh_username = local.ssh.username + ssh_password = local.ssh.password + ssh_handshake_attempts = local.ssh.handshake_attempts + ssh_private_key_file = "vagrant/insecure_key" + + vm_name = "packer-${local.name}" + disk_size = "${local.disk_size}000" + cpus = local.cpus + memory = local.memory + headless = var.headless + guest_os_type = "Linux_64" + + http_content = var.http_files + http_directory = var.http_directory + cd_content = var.cd_content + cd_files = var.cd_files + cd_label = var.cd_label +}