Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HD-26283 Fix removal of default vagrant user for OVA #3596

Merged
merged 3 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ fetch:
-o ${PACKER_CACHE_DIR}/id_rsa_vagrant
chmod 600 ${PACKER_CACHE_DIR}/id_rsa_vagrant

# Add the box using Vagrant
test -f ${PACKER_CACHE_DIR}/box/oracle9.ova \
|| curl -fL https://pmm-build-cache.s3.us-east-2.amazonaws.com/VBOXES/oracle9-202407.23.0.box -o ${PACKER_CACHE_DIR}/box/oracle9.ova

test -f ${PACKER_CACHE_DIR}/box/box.ovf \
|| VAGRANT_HOME=${PACKER_CACHE_DIR}/box vagrant box add bento/oraclelinux-9 --box-version ${BOX_VERSION} --provider virtualbox
|| tar -C ${PACKER_CACHE_DIR}/box -xvf ${PACKER_CACHE_DIR}/box/oracle9.ova

test -f ${PACKER_CACHE_DIR}/box/box.ovf \
|| cp -rp ${PACKER_CACHE_DIR}/box/boxes/bento-VAGRANTSLASH-oraclelinux-9/${BOX_VERSION}/amd64/virtualbox/* ${PACKER_CACHE_DIR}/box

# # Add the box using Vagrant
# test -f ${PACKER_CACHE_DIR}/box/box.ovf \
# || VAGRANT_HOME=${PACKER_CACHE_DIR}/box vagrant box add bento/oraclelinux-9 --box-version ${BOX_VERSION} --provider virtualbox

# test -f ${PACKER_CACHE_DIR}/box/box.ovf \
# || cp -rp ${PACKER_CACHE_DIR}/box/boxes/bento-VAGRANTSLASH-oraclelinux-9/${BOX_VERSION}/amd64/virtualbox/* ${PACKER_CACHE_DIR}/box

deps:
mkdir -p ${PACKER_CACHE_DIR} ~/bin || :
curl -fL https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip -o ${PACKER_CACHE_DIR}/packer.zip
Expand Down
34 changes: 34 additions & 0 deletions build/packer/ansible/roles/ami-ovf/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,37 @@

- name: PMM | Delete Azure user
shell: cd /tmp; nohup sh -c "trap '/usr/sbin/waagent -force -deprovision+user && sync' EXIT; sleep 600" </dev/null >/dev/null 2>&1 &

- name: Lock vagrant user
ansible.builtin.user:
name: vagrant
password_lock: true
when: ansible_virtualization_type == "virtualbox"

ademidoff marked this conversation as resolved.
Show resolved Hide resolved
- name: Configure systemd service to remove vagrant user
block:
- name: Create systemd service file
copy:
dest: /etc/systemd/system/remove-vagrant.service
content: |
[Unit]
Description=Remove vagrant user on first boot
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/userdel -r vagrant
ExecStartPost=/usr/bin/touch /etc/remove-vagrant-done

[Install]
WantedBy=multi-user.target
ConditionPathExists=!/etc/remove-vagrant-done

- name: Reload systemd to recognize the new service
command: systemctl daemon-reload

- name: Enable the remove-vagrant service
systemd:
name: remove-vagrant
enabled: true
when: ansible_virtualization_type == "virtualbox"
Loading