Skip to content

Commit

Permalink
build images as regular user (#133)
Browse files Browse the repository at this point in the history
- drop use of `sudo` for most templates
- fix `envsubst` use
- Makefile tidy up
  • Loading branch information
alexsander-souza authored Sep 6, 2023
1 parent 417f127 commit 9b9c695
Show file tree
Hide file tree
Showing 26 changed files with 91 additions and 81 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ ubuntu/packages/*.deb
ubuntu/packages/*.bin
ubuntu/packages/*.tar.gz
.vscode
*/http/*.ks
9 changes: 5 additions & 4 deletions centos6/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PACKER ?= packer
PACKER_LOG ?= 0
SUDO ?= sudo

export PACKER_LOG KS_PROXY

Expand All @@ -12,10 +11,12 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

centos6.tar.gz: check-deps clean http/centos6.ks
${SUDO} ${PACKER} init centos6.pkr.hcl && ${SUDO} ${PACKER} build centos6.pkr.hcl
${PACKER} init centos6.pkr.hcl && ${PACKER} build centos6.pkr.hcl

http/centos6.ks: http/centos6.ks.in
envsubst '$KS_PROXY' < $< | tee $@
envsubst '$${KS_PROXY}' < $< | tee $@

clean:
${SUDO} ${RM} -rf output-centos6 centos6.tar.gz http/centos6.ks
${RM} -rf output-centos6 centos6.tar.gz http/centos6.ks

.INTERMEDIATE: http/centos6.ks
4 changes: 2 additions & 2 deletions centos6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ be in packer-maas/centos6, where this file is located. Once in
packer-maas/centos6 you can generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build .
packer init
PACKER_LOG=1 packer build .
```

Note: centos6.pkr.hcl is configured to run Packer in headless mode. Only Packer
Expand Down
9 changes: 5 additions & 4 deletions centos7/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PACKER ?= packer
PACKER_LOG ?= 0
SUDO ?= sudo

export PACKER_LOG KS_PROXY

Expand All @@ -12,10 +11,12 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

centos7.tar.gz: clean check-deps http/centos7.ks
${SUDO} ${PACKER} init centos7.pkr.hcl && ${SUDO} ${PACKER} build centos7.pkr.hcl
${PACKER} init centos7.pkr.hcl && ${PACKER} build centos7.pkr.hcl

http/centos7.ks: http/centos7.ks.in
envsubst '$KS_PROXY' < $< | tee $@
envsubst '$${KS_PROXY}' < $< | tee $@

clean:
${SUDO} ${RM} -rf output-centos7 centos7.tar.gz http/centos7.ks
${RM} -rf output-centos7 centos7.tar.gz http/centos7.ks

.INTERMEDIATE: http/centos7.ks
4 changes: 2 additions & 2 deletions centos7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ be in packer-maas/centos7, where this file is located. Once in
packer-maas/centos7 you can generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build .
packer init
PACKER_LOG=1 packer build .
```

Note: centos7.pkr.hcl is configured to run Packer in headless mode. Only Packer
Expand Down
9 changes: 5 additions & 4 deletions centos8-stream/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PACKER ?= packer
PACKER_LOG ?= 0
SUDO ?= sudo

export PACKER_LOG KS_PROXY

Expand All @@ -12,10 +11,12 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

centos8-stream.tar.gz: check-deps clean http/centos8-stream.ks
${SUDO} ${PACKER} init centos8-stream.pkr.hcl && ${SUDO} ${PACKER} build centos8-stream.pkr.hcl
${PACKER} init centos8-stream.pkr.hcl && ${PACKER} build centos8-stream.pkr.hcl

http/centos8-stream.ks: http/centos8-stream.ks.in
envsubst '$KS_PROXY' < $< | tee $@
envsubst '$${KS_PROXY}' < $< | tee $@

clean:
${SUDO} ${RM} -rf output-centos8-stream centos8-stream.tar.gz http/centos8-stream.ks
${RM} -rf output-centos8-stream centos8-stream.tar.gz http/centos8-stream.ks

.INTERMEDIATE: http/centos8-stream.ks
4 changes: 2 additions & 2 deletions centos8-stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ be in packer-maas/centos8-stream, where this file is located. Once in
packer-maas/centos8-stream you can generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build .
packer init
PACKER_LOG=1 packer build .
```

Note: centos8-stream.pkr.hcl is configured to run Packer in headless mode. Only Packer
Expand Down
9 changes: 5 additions & 4 deletions centos8/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PACKER ?= packer
PACKER_LOG ?= 0
SUDO ?= sudo

export PACKER_LOG KS_PROXY

Expand All @@ -12,10 +11,12 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

centos8.tar.gz: check-deps clean http/centos8.ks
${SUDO} ${PACKER} init centos8.pkr.hcl && ${PACKER} build centos8.pkr.hcl
${PACKER} init centos8.pkr.hcl && ${PACKER} build centos8.pkr.hcl

http/centos8.ks: http/centos8.ks.in
envsubst '$KS_PROXY' < $< | tee $@
envsubst '$${KS_PROXY}' < $< | tee $@

clean:
${SUDO} ${RM} -rf output-centos8 centos8.tar.gz http/centos8.ks
${RM} -rf output-centos8 centos8.tar.gz http/centos8.ks

.INTERMEDIATE: http/centos8.ks
4 changes: 2 additions & 2 deletions centos8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ be in packer-maas/centos8, where this file is located. Once in
packer-maas/centos8 you can generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build .
packer init
PACKER_LOG=1 packer build .
```

Note: centos8.pkr.hcl is configured to run Packer in headless mode. Only Packer
Expand Down
9 changes: 5 additions & 4 deletions rhel7/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PACKER ?= packer
PACKER_LOG ?= 0
SUDO ?= sudo
ISO ?= ${RHEL7_ISO_PATH}

export PACKER_LOG KS_PROXY
Expand All @@ -13,10 +12,12 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

rhel7.tar.gz: check-deps clean http/rhel7.ks
${SUDO} ${PACKER} init rhel7.pkr.hcl && ${SUDO} ${PACKER} build -var "rhel7_iso_path=${ISO}" rhel7.pkr.hcl
${PACKER} init rhel7.pkr.hcl && ${PACKER} build -var "rhel7_iso_path=${ISO}" rhel7.pkr.hcl

http/rhel7.ks: http/rhel7.ks.in
envsubst '$KS_PROXY' < $< | tee $@
envsubst '$${KS_PROXY}' < $< | tee $@

clean:
${SUDO} ${RM} -rf output-rhel7 rhel7.tar.gz http/rhel7.ks
${RM} -rf output-rhel7 rhel7.tar.gz http/rhel7.ks

.INTERMEDIATE: http/rhel7.ks
4 changes: 2 additions & 2 deletions rhel7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ be in packer-maas/rhel7, where this file is located. Once in packer-maas/rhel7
you can generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build -var 'rhel7_iso_path=/PATH/TO/rhel-server-7.9-x86_64-dvd.iso' .
packer init
PACKER_LOG=1 packer build -var 'rhel7_iso_path=/PATH/TO/rhel-server-7.9-x86_64-dvd.iso' .
```

Note: rhel7.pkr.hcl is configured to run Packer in headless mode. Only Packer
Expand Down
9 changes: 5 additions & 4 deletions rhel8/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PACKER ?= packer
PACKER_LOG ?= 0
SUDO ?= sudo
ISO ?= ${RHEL8_ISO_PATH}

export PACKER_LOG KS_PROXY
Expand All @@ -13,10 +12,12 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

rhel8.tar.gz: check-deps clean http/rhel8.ks
${SUDO} ${PACKER} init rhel8.pkr.hcl && ${SUDO} ${PACKER} build -var "rhel8_iso_path=${ISO}" rhel8.pkr.hcl
${PACKER} init rhel8.pkr.hcl && ${PACKER} build -var "rhel8_iso_path=${ISO}" rhel8.pkr.hcl

http/rhel8.ks: http/rhel8.ks.in
envsubst '$KS_PROXY' < $< | tee $@
envsubst '$${KS_PROXY}' < $< | tee $@

clean:
${SUDO} ${RM} -rf output-rhel8 rhel8.tar.gz http/rhel8.ks
${RM} -rf output-rhel8 rhel8.tar.gz http/rhel8.ks

.INTERMEDIATE: http/rhel8.ks
4 changes: 2 additions & 2 deletions rhel8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ be in packer-maas/rhel8, where this file is located. Once in packer-maas/rhel8
you can generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build -var 'rhel8_iso_path=/PATH/TO/rhel-8.3-x86_64-dvd.iso' .
packer init
PACKER_LOG=1 packer build -var 'rhel8_iso_path=/PATH/TO/rhel-8.3-x86_64-dvd.iso' .
```

Note: rhel8.pkr.hcl is configured to run Packer in headless mode. Only Packer
Expand Down
9 changes: 5 additions & 4 deletions rhel9/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PACKER ?= packer
PACKER_LOG ?= 0
SUDO ?= sudo
ISO ?= rhel-baseos-9.1-x86_64-dvd.iso

export PACKER_LOG KS_PROXY
Expand All @@ -13,10 +12,12 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

rhel9.tar.gz: check-deps clean http/rhel9.ks
${SUDO} ${PACKER} init rhel9.pkr.hcl && ${SUDO} ${PACKER} build -var "rhel9_iso_path=${ISO}" rhel9.pkr.hcl
${PACKER} init rhel9.pkr.hcl && ${PACKER} build -var "rhel9_iso_path=${ISO}" rhel9.pkr.hcl

http/rhel9.ks: http/rhel9.ks.in
envsubst '$KS_PROXY' < $< | tee $@
envsubst '$${KS_PROXY}' < $< | tee $@

clean:
${SUDO} ${RM} -rf output-rhel9 rhel9.tar.gz http/rhel9.ks
${RM} -rf output-rhel9 rhel9.tar.gz http/rhel9.ks

.INTERMEDIATE: http/rhel9.ks
4 changes: 2 additions & 2 deletions rhel9/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ be in packer-maas/rhel9, where this file is located. Once in packer-maas/rhel9
you can generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build -var 'rhel9_iso_path=/PATH/TO/rhel-baseos-9.1-x86_64-dvd.iso' .
packer init
PACKER_LOG=1 packer build -var 'rhel9_iso_path=/PATH/TO/rhel-baseos-9.1-x86_64-dvd.iso' .
```

Note: rhel9.pkr.hcl is configured to run Packer in headless mode. Only Packer
Expand Down
9 changes: 5 additions & 4 deletions rocky8/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PACKER ?= packer
PACKER_LOG ?= 0
SUDO ?= sudo

export PACKER_LOG KS_PROXY

Expand All @@ -12,10 +11,12 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

rocky8.tar.gz: check-deps clean http/rocky.ks
${SUDO} ${PACKER} init rocky8.pkr.hcl && ${SUDO} ${PACKER} build rocky8.pkr.hcl
${PACKER} init rocky8.pkr.hcl && ${PACKER} build rocky8.pkr.hcl

http/rocky.ks: http/rocky.ks.in
envsubst '$KS_PROXY' < $< | tee $@
envsubst '$${KS_PROXY}' < $< | tee $@

clean:
${SUDO} ${RM} -rf output-rocky8 rocky8.tar.gz http/rocky.ks
${RM} -rf output-rocky8 rocky8.tar.gz http/rocky.ks

.INTERMEDIATE: http/rocky.ks
4 changes: 2 additions & 2 deletions rocky8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ make
You can also manually run packer. Set your current working directory to packer-maas/rocky8, where this file resides, and generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build .
packer init
PACKER_LOG=1 packer build .
```

The installation runs in a non-interactive mode.
Expand Down
9 changes: 5 additions & 4 deletions rocky9/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PACKER ?= packer
PACKER_LOG ?= 0
SUDO ?= sudo

export PACKER_LOG KS_PROXY

Expand All @@ -12,10 +11,12 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

rocky9.tar.gz: check-deps clean http/rocky.ks
${SUDO} ${PACKER} init rocky9.pkr.hcl && ${SUDO} ${PACKER} build rocky9.pkr.hcl
${PACKER} init rocky9.pkr.hcl && ${PACKER} build rocky9.pkr.hcl

http/rocky.ks: http/rocky.ks.in
envsubst '$KS_PROXY' < $< | tee $@
envsubst '$${KS_PROXY}' < $< | tee $@

clean:
${SUDO} ${RM} -rf output-rocky9 rocky9.tar.gz http/rocky.ks
${RM} -rf output-rocky9 rocky9.tar.gz http/rocky.ks

.INTERMEDIATE: http/rocky.ks
2 changes: 1 addition & 1 deletion rocky9/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ make
You can also manually run packer. Set your current working directory to packer-maas/rocky9, where this file resides, and generate an image with:

```shell
sudo PACKER_LOG=1 packer build .
PACKER_LOG=1 packer build .
```

The installation runs in a non-interactive mode.
Expand Down
2 changes: 1 addition & 1 deletion scripts/fuse-nbd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function mount_part() {
done
case "${FUSEDRV}" in
"fusefat") fusefat ${DEV}/nbd ${MOUNTPOINT} -o rw+ -s ;;
"fuse2fs") fuse2fs ${DEV}/nbd ${MOUNTPOINT} ;;
"fuse2fs") fuse2fs ${DEV}/nbd ${MOUNTPOINT} -o fakeroot ;;
*) echo "Unsupported Fuse driver" && exit 1 ;;
esac
}
Expand Down
5 changes: 2 additions & 3 deletions sles12/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
PACKER ?= packer
PACKER_LOG ?= 0
export PACKER_LOG
SUDO ?= sudo
ISO ?= SLES12-SP5-JeOS.x86_64-12.5-OpenStack-Cloud-GM.qcow2

.PHONY: all clean
Expand All @@ -12,10 +11,10 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

sles12.tar.gz: check-deps clean
${SUDO} ${PACKER} init sles.pkr.hcl && ${SUDO} ${PACKER} build -var "sles12_iso_path=${ISO}" -on-error=ask sles.pkr.hcl
${PACKER} init sles.pkr.hcl && ${PACKER} build -var "sles12_iso_path=${ISO}" -on-error=ask sles.pkr.hcl

clean:
${SUDO} ${RM} -rf output-sles12 sles12.tar.gz
${RM} -rf output-sles12 sles12.tar.gz

lint:
packer validate .
Expand Down
4 changes: 2 additions & 2 deletions sles12/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ make ISO=/PATH/TO/SLES12-SP5-JeOS.x86_64-12.5-OpenStack-Cloud-GM.qcow2
Alternatively you can manually run packer. Your current working directory must be in `packer-maas/sles12`, where this file is located. Once in `packer-maas/sles12` you can generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build -var 'sles_iso_path=/PATH/TO/SLES12-SP5-JeOS.x86_64-12.5-OpenStack-Cloud-GM.qcow2' .
packer init
PACKER_LOG=1 packer build -var 'sles_iso_path=/PATH/TO/SLES12-SP5-JeOS.x86_64-12.5-OpenStack-Cloud-GM.qcow2' .
```

Note: `sles.pkr.hcl` is configured to run Packer in headless mode. Only Packer output will be seen. If you wish to see the installation output connect to the VNC port given in the packer output or change the value of `headless` to false in `sles.pkr.hcl`.
Expand Down
5 changes: 2 additions & 3 deletions sles15/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
PACKER ?= packer
PACKER_LOG ?= 0
export PACKER_LOG
SUDO ?= sudo
ISO ?= SLE-15-SP4-Full-x86_64-GM-Media1.iso

.PHONY: all clean
Expand All @@ -12,10 +11,10 @@ check-deps:
dpkg -s libnbd-bin nbdkit packer fuse2fs > /dev/null

sles15.tar.gz: check-deps clean
${SUDO} ${PACKER} init sles.pkr.hcl && ${SUDO} ${PACKER} build -var "sles15_iso_path=${ISO}" -on-error=ask sles.pkr.hcl
${PACKER} init sles.pkr.hcl && ${PACKER} build -var "sles15_iso_path=${ISO}" -on-error=ask sles.pkr.hcl

clean:
${SUDO} ${RM} -rf output-sles15 sles15.tar.gz
${RM} -rf output-sles15 sles15.tar.gz

lint:
packer validate .
Expand Down
4 changes: 2 additions & 2 deletions sles15/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ be in `packer-maas/sles15`, where this file is located. Once in packer-maas/sles
you can generate an image with:

```shell
sudo packer init
sudo PACKER_LOG=1 packer build -var 'sles15_iso_path=/PATH/TO/SLE-15-SP4-Full-x86_64-GM-Media1.iso' .
packer init
PACKER_LOG=1 packer build -var 'sles15_iso_path=/PATH/TO/SLE-15-SP4-Full-x86_64-GM-Media1.iso' .
```

Note: `sles.pkr.hcl` is configured to run Packer in headless mode. Only Packer
Expand Down
Loading

0 comments on commit 9b9c695

Please sign in to comment.