Skip to content

Commit

Permalink
Refactor image cleaning part
Browse files Browse the repository at this point in the history
  • Loading branch information
ruzickap committed Apr 5, 2020
1 parent a6ca9d4 commit 08baf3e
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 89 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/packer-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Download Packer
run: |
PACKER_LATEST_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "ansible/roles/ansible-role-my_common_defaults"]
path = ansible/roles/ansible-role-my_common_defaults
url = https://github.com/ruzickap/ansible-role-my_common_defaults.git
[submodule "scripts/linux-common/packer-virt-sysprep"]
path = scripts/linux-common/packer-virt-sysprep
url = https://github.com/ruzickap/packer-virt-sysprep.git
17 changes: 14 additions & 3 deletions my_centos-7.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -S -E bash -x '{{ .Path }}'",
"execute_command": "echo 'vagrant' | sudo -S -E bash '{{ .Path }}'",
"scripts": [
"scripts/linux-common/vagrant.sh"
]
Expand All @@ -114,9 +114,20 @@
},
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -S -E bash -x '{{ .Path }}'",
"execute_command": "sudo -E bash '{{ .Path }}'",
"scripts": [
"scripts/linux-common/cleanup.sh"
"scripts/linux-common/packer-virt-sysprep/sysprep-op-dhcp-client-state.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-firewall-rules.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-logfiles.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-machine-id.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-mail-spool.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-network.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-package-manager-cache.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-rpm-db.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-ssh-hostkeys.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-tmp-files.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-yum-uuid.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-disk-space.sh"
]
}
],
Expand Down
16 changes: 11 additions & 5 deletions my_ubuntu-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -S -E bash -x '{{ .Path }}'",
"execute_command": "echo 'vagrant' | sudo -S -E bash '{{ .Path }}'",
"scripts": [
"scripts/linux-common/vagrant.sh",
"scripts/ubuntu/update.sh",
"scripts/ubuntu/add_libpam-systemd.sh",
"scripts/ubuntu/disable_apt-daily.sh",
"scripts/ubuntu/virtualbox-guest.sh",
"scripts/linux-common/vagrant.sh"
"scripts/ubuntu/virtualbox-guest.sh"
]
},
{
Expand All @@ -135,9 +135,15 @@
},
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -S -E bash -x '{{ .Path }}'",
"execute_command": "sudo -E bash '{{ .Path }}'",
"scripts": [
"scripts/linux-common/cleanup.sh"
"scripts/linux-common/packer-virt-sysprep/sysprep-op-dhcp-client-state.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-logfiles.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-machine-id.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-package-manager-cache.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-ssh-hostkeys.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-tmp-files.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-disk-space.sh"
]
}
],
Expand Down
70 changes: 0 additions & 70 deletions scripts/linux-common/cleanup.sh

This file was deleted.

1 change: 1 addition & 0 deletions scripts/linux-common/packer-virt-sysprep
Submodule packer-virt-sysprep added at b7df8a
2 changes: 1 addition & 1 deletion scripts/ubuntu/add_libpam-systemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Description: https://serverfault.com/questions/706475/ssh-sessions-hang-on-shutdown-reboot

export DEBIAN_FRONTEND="noninteractive"
apt-get install -qq -y --no-install-recommends libpam-systemd
apt-get install -qq -y --no-install-recommends libpam-systemd > /dev/null
2 changes: 1 addition & 1 deletion scripts/ubuntu/disable-netplan-networkd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
# In short the /etc/netplan/01-netcfg.yaml should not be on the Ubuntu Desktop installation when using Vagrant otherwise `vagrant up` is hanging.

if [[ -s /etc/netplan/01-netcfg.yaml ]] ; then
rm -v /etc/netplan/01-netcfg.yaml
rm /etc/netplan/01-netcfg.yaml
fi
2 changes: 0 additions & 2 deletions scripts/ubuntu/disable_apt-daily.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

# Issue: https://github.com/boxcutter/ubuntu/pull/74

echo "Disabling unattended upgrades"

cat > /etc/apt/apt.conf.d/51disable-unattended-upgrades << EOF
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";
Expand Down
2 changes: 1 addition & 1 deletion scripts/ubuntu/spice-vdagent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ if grep -q QEMU /proc/scsi/scsi; then
echo "*** Installing spice-vdagent"

export DEBIAN_FRONTEND="noninteractive"
apt-get install -y -qq --no-install-recommends spice-vdagent
apt-get install -y -qq --no-install-recommends spice-vdagent > /dev/null
fi
12 changes: 9 additions & 3 deletions ubuntu-desktop.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,21 @@
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -S -E bash -x '{{ .Path }}'",
"execute_command": "echo 'vagrant' | sudo -S -E bash '{{ .Path }}'",
"scripts": [
"scripts/linux-common/vagrant.sh",
"scripts/ubuntu/update.sh",
"scripts/ubuntu/disable_apt-daily.sh",
"scripts/ubuntu/spice-vdagent.sh",
"scripts/ubuntu/virtualbox-guest-x11.sh",
"scripts/ubuntu/disable-netplan-networkd.sh",
"scripts/linux-common/vagrant.sh",
"scripts/linux-common/cleanup.sh"
"scripts/linux-common/packer-virt-sysprep/sysprep-op-dhcp-client-state.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-logfiles.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-machine-id.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-package-manager-cache.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-ssh-hostkeys.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-tmp-files.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-disk-space.sh"
]
}
],
Expand Down
12 changes: 9 additions & 3 deletions ubuntu-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,20 @@
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{ .Vars }} sudo -S -E bash -x '{{ .Path }}'",
"execute_command": "echo 'vagrant' | sudo -S -E bash '{{ .Path }}'",
"scripts": [
"scripts/linux-common/vagrant.sh",
"scripts/ubuntu/update.sh",
"scripts/ubuntu/add_libpam-systemd.sh",
"scripts/ubuntu/disable_apt-daily.sh",
"scripts/ubuntu/virtualbox-guest.sh",
"scripts/linux-common/vagrant.sh",
"scripts/linux-common/cleanup.sh"
"scripts/linux-common/packer-virt-sysprep/sysprep-op-dhcp-client-state.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-logfiles.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-machine-id.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-package-manager-cache.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-ssh-hostkeys.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-tmp-files.sh",
"scripts/linux-common/packer-virt-sysprep/sysprep-op-disk-space.sh"
]
}
],
Expand Down

0 comments on commit 08baf3e

Please sign in to comment.