Skip to content

Commit f972a92

Browse files
PMM-7 Fix removal of default vagrant user. (#3595)
1 parent 79a2310 commit f972a92

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

build/Makefile

+9-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ fetch-el9:
2222
-o ${PACKER_CACHE_DIR}/id_rsa_vagrant
2323
chmod 600 ${PACKER_CACHE_DIR}/id_rsa_vagrant
2424
test -f ${PACKER_CACHE_DIR}/box/oracle9.ova \
25-
|| wget --progress=dot:giga https://vagrantcloud.com/bento/boxes/oracle-9.0/versions/202207.20.0/providers/virtualbox.box -O ${PACKER_CACHE_DIR}/box/oracle9.ova
25+
|| 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
2626

27-
# NOTE: image from vagrant registry is twice as large
2827
test -f ${PACKER_CACHE_DIR}/box/box.ovf \
29-
|| tar -C ${PACKER_CACHE_DIR}/box -xvf ${PACKER_CACHE_DIR}/box/oracle9.ova
28+
|| tar -C ${PACKER_CACHE_DIR}/box -xvf ${PACKER_CACHE_DIR}/box/oracle9.ova
29+
30+
# # Add the box using Vagrant
31+
# test -f ${PACKER_CACHE_DIR}/box/box.ovf \
32+
# || VAGRANT_HOME=${PACKER_CACHE_DIR}/box vagrant box add bento/oraclelinux-9 --box-version ${BOX_VERSION} --provider virtualbox
33+
34+
test -f ${PACKER_CACHE_DIR}/box/box.ovf \
35+
|| cp -rp ${PACKER_CACHE_DIR}/box/boxes/bento-VAGRANTSLASH-oraclelinux-9/${BOX_VERSION}/amd64/virtualbox/* ${PACKER_CACHE_DIR}/box
3036

3137
deps:
3238
mkdir -p ${PACKER_CACHE_DIR} ~/bin || :

build/ansible/roles/ami-ovf/tasks/main.yml

+34
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,37 @@
103103

104104
- name: PMM | Delete Azure user
105105
shell: cd /tmp; nohup sh -c "trap '/usr/sbin/waagent -force -deprovision+user && sync' EXIT; sleep 600" </dev/null >/dev/null 2>&1 &
106+
107+
- name: Lock vagrant user
108+
ansible.builtin.user:
109+
name: vagrant
110+
password_lock: true
111+
when: ansible_virtualization_type == "virtualbox"
112+
113+
- name: Configure systemd service to remove vagrant user
114+
block:
115+
- name: Create systemd service file
116+
copy:
117+
dest: /etc/systemd/system/remove-vagrant.service
118+
content: |
119+
[Unit]
120+
Description=Remove vagrant user on first boot
121+
After=multi-user.target
122+
123+
[Service]
124+
Type=oneshot
125+
ExecStart=/usr/sbin/userdel -r vagrant
126+
ExecStartPost=/usr/bin/touch /etc/remove-vagrant-done
127+
128+
[Install]
129+
WantedBy=multi-user.target
130+
ConditionPathExists=!/etc/remove-vagrant-done
131+
132+
- name: Reload systemd to recognize the new service
133+
command: systemctl daemon-reload
134+
135+
- name: Enable the remove-vagrant service
136+
systemd:
137+
name: remove-vagrant
138+
enabled: true
139+
when: ansible_virtualization_type == "virtualbox"

0 commit comments

Comments
 (0)