Skip to content

Building locally doesn't work out of the box #186

@slifty

Description

@slifty

I tried following the README instructions for building things locally, using an AMI keypair with the proper access.

Things don't work out of the box.

Some example steps I took beyond the readme to get further in the build process:

  1. Installing the packer plugins used in the CI scripts:
packer plugins install "github.com/hashicorp/amazon"
packer plugins install "github.com/hashicorp/ansible"
  1. Explicitly setting the provisioner user that runs setup.yml:
"provisioners": [
    ...,
    {
      ...
      "playbook_file": "../provisioners/setup.yml",
      "type": "ansible",
      "user": "admin"
    },
  1. Explicitly setting the become_user to root for the add_users step of setup.yml:
- name: Add Users
  hosts: default
  become: true
  become_user: root
  1. Changing to lineinfile instead of copy for addlowing sudo without password for sudo group:
    - name: Allow sudo without password for sudo group
      lineinfile:
        path: /etc/sudoers.d/sudo_nopasswd
        create: yes
        line: "%sudo  ALL=(ALL:ALL) NOPASSWD:ALL"
        mode: '0440'

At this point I got another error:

    amazon-ebs: TASK [willshersystems.sshd : Re-raise the error] *******************************
    amazon-ebs: task path: /Users/slifty/.ansible/roles/willshersystems.sshd/tasks/install.yml:133
    amazon-ebs: fatal: [default]: FAILED! => {"changed": false, "msg": {"failed": true, "msg": "failed to transfer file to /Users/slifty/.ansible/tmp/ansible-local-20988b2ymf0u8/tmpc5p22odf/sshd_config.j2 /home/admin/.ansible/tmp/ansible-tmp-1745874316.012822-21040-96878840327480/source:\n\n"}}
    amazon-ebs:
    amazon-ebs: TASK [willshersystems.sshd : Remove temporary host keys] ***********************
    amazon-ebs: task path: /Users/slifty/.ansible/roles/willshersystems.sshd/tasks/install.yml:137
    amazon-ebs: skipping: [default] => {"changed": false, "false_condition": "sshd_test_hostkey.path is defined", "skip_reason": "Conditional result was False"}

and decided... I'm starting to diverge too far from CI, and I don't know if I'm doing so in a way that would actually break CI, so I created this issue instead.

I think it is important for us to be able to build these images locally to test out our build state, rather than having to push to github and trigger a CI build on a branch. That said, this is a large enough task to represent its own prioritization, and possibly some refactoring of this repository to have packer run inside of a container to ensure consistency.

In case it helps, I'm using MacOS 15.4 on an M1 chip. I would be curious if others have a smoother experience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions