Commit c7183d54 authored by Francois Le Corre's avatar Francois Le Corre Committed by Thomas Gambier

ubuntu 20.04 and ansible file cleanup

parent 0c62baab
......@@ -13,22 +13,6 @@
- easy_install:
name: slapos.libnetworkcache
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' debian7.json >> log/debian7-{{ item.name }}.log
args:
creates: output-debian7-{{ item.size }}G-{{ item.name }}
with_items:
- { name: "vm-bootstrap", size: "200", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' debian8.json >> log/debian8-{{ item.name }}.log
args:
creates: output-debian8-{{ item.size }}G-{{ item.name }}
with_items:
- { name: "vm-bootstrap", size: "200", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' debian9.json >> log/debian9-{{ item.name }}.log
args:
creates: output-debian9-{{ item.size }}G-{{ item.name }}
......@@ -37,41 +21,44 @@
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' ubuntu-14.04-server-amd64.json >> log/ubuntu-14-server-amd64-{{ item.name }}.log
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' debian10.json >> log/debian10-{{ item.name }}.log
args:
creates: output-ubuntu-14-server-{{ item.size }}G-{{ item.name }}
creates: output-debian10-{{ item.size }}G-{{ item.name }}
with_items:
- { name: "vm-bootstrap", size: "200", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' ubuntu-16.04-server-amd64.json >> log/ubuntu-16.04-server-amd64-{{ item.name }}.log
args:
creates: output-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}
with_items:
- { name: "vm-bootstrap", size: "200", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' ubuntu-16.10-server-amd64.json >> log/ubuntu-16-server-amd64-{{ item.name }}.log
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' ubuntu-18.04-server-amd64.json >> log/ubuntu-18.04-server-amd64-{{ item.name }}.log
args:
creates: output-ubuntu-16-server-{{ item.size }}G-{{ item.name }}
creates: output-ubuntu-18.04-server-{{ item.size }}G-{{ item.name }}
with_items:
- { name: "vm-bootstrap", size: "200", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' centos-6.7.json >> log/centos-6-{{ item.name }}.log
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' ubuntu-20.04-server-amd64.json >> log/ubuntu-20.04-server-amd64-{{ item.name }}.log
args:
creates: output-centos-6-{{ item.size }}G-{{ item.name }}
creates: output-ubuntu-20.04-server-{{ item.size }}G-{{ item.name }}
with_items:
- { name: "vm-bootstrap", size: "200", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' centos-7.2.json >> log/centos-7.2-{{ item.name }}.log
# - shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' centos8.json >> log/centos8-{{ item.name }}.log
# args:
# creates: output-centos8-{{ item.size }}G-{{ item.name }}
# with_items:
# - { name: "vm-bootstrap", size: "200", script: "scripts/vm-bootstrap.sh"}
# - { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
# - { name: "vm-bootstrap", size: "25", script: "scripts/vm-bootstrap.sh"}
- shell: PATH=$PATH:/opt/packer/ packer build -var 'disk_size={{ item.size }}' -var 'name={{ item.name }}' -var 'custom_script={{ item.script }}' centos7.json >> log/centos7-{{ item.name }}.log
args:
creates: output-centos7.2-{{ item.size }}G-{{ item.name }}
creates: output-centos7-{{ item.size }}G-{{ item.name }}
with_items:
- { name: "vm-bootstrap", size: "200", script: "scripts/vm-bootstrap.sh"}
- { name: "vm-bootstrap", size: "50", script: "scripts/vm-bootstrap.sh"}
......@@ -80,23 +67,6 @@
#### Genetation of images are over.
#### Start compress everything
- shell: gzip output-debian7-{{ item.size }}G-{{ item.name }}/packer-debian7-{{ item.size }}G-{{ item.name }}
args:
creates: output-debian7-{{ item.size }}G-{{ item.name }}/packer-debian7-{{ item.size }}G-{{ item.name }}.gz
with_items:
- { name: "vm-bootstrap", size: "200"}
- { name: "vm-bootstrap", size: "50"}
- { name: "vm-bootstrap", size: "25"}
ignore_errors: True
- shell: gzip output-debian8-{{ item.size }}G-{{ item.name }}/packer-debian8-{{ item.size }}G-{{ item.name }}
args:
creates: output-debian8-{{ item.size }}G-{{ item.name }}/packer-debian8-{{ item.size }}G-{{ item.name }}.gz
with_items:
- { name: "vm-bootstrap", size: "200"}
- { name: "vm-bootstrap", size: "50"}
- { name: "vm-bootstrap", size: "25"}
ignore_errors: True
- shell: gzip output-debian9-{{ item.size }}G-{{ item.name }}/packer-debian9-{{ item.size }}G-{{ item.name }}
args:
......@@ -107,45 +77,45 @@
- { name: "vm-bootstrap", size: "25"}
ignore_errors: True
- shell: gzip output-ubuntu-14-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-14-server-{{ item.size }}G-{{ item.name }}
- shell: gzip output-debian10-{{ item.size }}G-{{ item.name }}/packer-debian10-{{ item.size }}G-{{ item.name }}
args:
creates: output-ubuntu-14-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-14-server-{{ item.size }}G-{{ item.name }}.gz
creates: output-debian10-{{ item.size }}G-{{ item.name }}/packer-debian10-{{ item.size }}G-{{ item.name }}.gz
with_items:
- { name: "vm-bootstrap", size: "200"}
- { name: "vm-bootstrap", size: "50"}
- { name: "vm-bootstrap", size: "25"}
ignore_errors: True
- shell: gzip output-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}
- shell: gzip output-ubuntu-18.04-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-18.04-server-{{ item.size }}G-{{ item.name }}
args:
creates: output-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-16.04-server-{{ item.size }}G-{{ item.name }}.gz
creates: output-ubuntu-18.04-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-18.04-server-{{ item.size }}G-{{ item.name }}.gz
with_items:
- { name: "vm-bootstrap", size: "200"}
- { name: "vm-bootstrap", size: "50"}
- { name: "vm-bootstrap", size: "25"}
ignore_errors: True
- shell: gzip output-ubuntu-16-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-16-server-{{ item.size }}G-{{ item.name }}
- shell: gzip output-ubuntu-20.04-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-20.04-server-{{ item.size }}G-{{ item.name }}
args:
creates: output-ubuntu-16-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-16-server-{{ item.size }}G-{{ item.name }}.gz
creates: output-ubuntu-20.04-server-{{ item.size }}G-{{ item.name }}/packer-ubuntu-20.04-server-{{ item.size }}G-{{ item.name }}.gz
with_items:
- { name: "vm-bootstrap", size: "200"}
- { name: "vm-bootstrap", size: "50"}
- { name: "vm-bootstrap", size: "25"}
ignore_errors: True
- shell: gzip output-centos-6-{{ item.size }}G-{{ item.name }}/packer-centos-6-{{ item.size }}G-{{ item.name }}
- shell: gzip output-centos8-{{ item.size }}G-{{ item.name }}/packer-centos8-{{ item.size }}G-{{ item.name }}
args:
creates: output-centos-6-{{ item.size }}G-{{ item.name }}/packer-centos-6-{{ item.size }}G-{{ item.name }}.gz
creates: output-centos8-{{ item.size }}G-{{ item.name }}/packer-centos8-{{ item.size }}G-{{ item.name }}.gz
with_items:
- { name: "vm-bootstrap", size: "200"}
- { name: "vm-bootstrap", size: "50"}
- { name: "vm-bootstrap", size: "25"}
ignore_errors: True
- shell: gzip output-centos7.2-{{ item.size }}G-{{ item.name }}/packer-centos7.2-{{ item.size }}G-{{ item.name }}
- shell: gzip output-centos7-{{ item.size }}G-{{ item.name }}/packer-centos7-{{ item.size }}G-{{ item.name }}
args:
creates: output-centos7.2-{{ item.size }}G-{{ item.name }}/packer-centos7.2-{{ item.size }}G-{{ item.name }}.gz
creates: output-centos7-{{ item.size }}G-{{ item.name }}/packer-centos7-{{ item.size }}G-{{ item.name }}.gz
with_items:
- { name: "vm-bootstrap", size: "200"}
- { name: "vm-bootstrap", size: "50"}
......@@ -162,70 +132,22 @@
sha512sum $FILE >> SHA512SUM.txt
md5sum $FILE >> MD5SUM.txt
with_items:
- { name: "vm-bootstrap", size: "200", distro: "debian8"}
- { name: "vm-bootstrap", size: "50", distro: "debian8"}
- { name: "vm-bootstrap", size: "25", distro: "debian8"}
- { name: "vm-bootstrap", size: "200", distro: "debian7"}
- { name: "vm-bootstrap", size: "50", distro: "debian7"}
- { name: "vm-bootstrap", size: "25", distro: "debian7"}
- { name: "vm-bootstrap", size: "200", distro: "debian9"}
- { name: "vm-bootstrap", size: "50", distro: "debian9"}
- { name: "vm-bootstrap", size: "25", distro: "debian9"}
- { name: "vm-bootstrap", size: "200", distro: "centos7.2"}
- { name: "vm-bootstrap", size: "50", distro: "centos7.2"}
- { name: "vm-bootstrap", size: "25", distro: "centos7.2"}
- { name: "vm-bootstrap", size: "200", distro: "centos-6"}
- { name: "vm-bootstrap", size: "50", distro: "centos-6"}
- { name: "vm-bootstrap", size: "25", distro: "centos-6"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-16-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-16-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-16-server"}
#### End of build SHA512SUM.txt
- stat: path=/etc/opt/shacache/shacache.cfg
register: shacache_config
- name: Upload a list of images to shacache, there is no verification for now
shell: |
FILE=output-{{ item.distro }}-{{ item.size }}G-{{ item.name }}/packer-{{ item.distro }}-{{ item.size }}G-{{ item.name }}.gz
networkcache-upload --prefix-key packerimage- --url $FILE --file $FILE /etc/opt/shacache/shacache.cfg
SHA512SUM=$(cat SHA512SUM.txt | grep packer-{{ item.distro }}-{{ item.size }}G-{{ item.name }}.gz | cut -d ' ' -f1)
BASE_URL=$(cat /etc/opt/shacache/shacache.cfg | grep 'download-cache-url' | cut -d' ' -f3)
MD5SUM=$(cat MD5SUM.txt | grep packer-{{ item.distro }}-{{ item.size }}G-{{ item.name }}.gz | cut -d ' ' -f1)
echo "packer-{{ item.distro }}-{{ item.size }}G-{{ item.name }}.gz $BASE_URL/$SHA512SUM $MD5SUM" >> URL.txt
with_items:
- { name: "vm-bootstrap", size: "200", distro: "debian8"}
- { name: "vm-bootstrap", size: "50", distro: "debian8"}
- { name: "vm-bootstrap", size: "25", distro: "debian8"}
- { name: "vm-bootstrap", size: "200", distro: "debian7"}
- { name: "vm-bootstrap", size: "50", distro: "debian7"}
- { name: "vm-bootstrap", size: "25", distro: "debian7"}
- { name: "vm-bootstrap", size: "200", distro: "debian9"}
- { name: "vm-bootstrap", size: "50", distro: "debian9"}
- { name: "vm-bootstrap", size: "25", distro: "debian9"}
- { name: "vm-bootstrap", size: "200", distro: "centos7.2"}
- { name: "vm-bootstrap", size: "50", distro: "centos7.2"}
- { name: "vm-bootstrap", size: "25", distro: "centos7.2"}
- { name: "vm-bootstrap", size: "200", distro: "centos-6"}
- { name: "vm-bootstrap", size: "50", distro: "centos-6"}
- { name: "vm-bootstrap", size: "25", distro: "centos-6"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-14-server"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-16.04-server"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-16-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-16-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-16-server"}
when: shacache_config.stat.exists == True and upload_shacache == "yes"
- { name: "vm-bootstrap", size: "200", distro: "debian10"}
- { name: "vm-bootstrap", size: "50", distro: "debian10"}
- { name: "vm-bootstrap", size: "25", distro: "debian10"}
- { name: "vm-bootstrap", size: "200", distro: "centos7"}
- { name: "vm-bootstrap", size: "50", distro: "centos7"}
- { name: "vm-bootstrap", size: "25", distro: "centos7"}
- { name: "vm-bootstrap", size: "200", distro: "centos8"}
- { name: "vm-bootstrap", size: "50", distro: "centos8"}
- { name: "vm-bootstrap", size: "25", distro: "centos8"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-18.04-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-18.04-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-18.04-server"}
- { name: "vm-bootstrap", size: "200", distro: "ubuntu-20.04-server"}
- { name: "vm-bootstrap", size: "50", distro: "ubuntu-20.04-server"}
- { name: "vm-bootstrap", size: "25", distro: "ubuntu-20.04-server"}
d-i preseed/include string ../preseed-ubuntu.cfg
d-i preseed/early_command string \
mkdir -p /usr/lib/post-base-installer.d && \
echo "sed -i -e 's/^in-target.*tasksel.*/#\\0/' /var/lib/dpkg/info/pkgsel.postinst" > /usr/lib/post-base-installer.d/90skip-tasksel && \
chmod +x /usr/lib/post-base-installer.d/90skip-tasksel
d-i preseed/late_command string \
echo 'Defaults:slapos !requiretty' > /target/etc/sudoers.d/slapos; \
echo 'slapos ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/slapos; \
chmod 440 /target/etc/sudoers.d/slapos ; \
ln -sf /dev/null /target/etc/systemd/network/99-default.link; \
in-target update-initramfs -u
{
"variables": {
"user": "slapos",
"password": "slapos",
"domain": "",
"disk_size": "20",
"name": "image",
"custom_script": "scripts/empty.sh"
},
"builders":
[
{
"name": "ubuntu-20.04-server-{{ user `disk_size`}}G-{{ user `name`}}",
"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": "{{ user `disk_size`}}000",
"headless": true,
"iso_checksum": "9d2b54506f8f9fdad6b72e45aff0f0de",
"iso_url": "http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/ubuntu-20.04-legacy-server-amd64.iso",
"iso_checksum_type": "md5",
"http_directory": "http",
"ssh_username": "{{user `user`}}",
"ssh_password": "{{user `password`}}",
"ssh_wait_timeout": "1800s",
"shutdown_command": "echo '{{user `password`}}'|sudo -S shutdown -P now",
"boot_wait": "2s",
"boot_command": [
"<esc><wait>",
"<esc><wait>",
"<enter><wait>",
"/install/vmlinuz ",
"initrd=/install/initrd.gz ",
"auto=true ",
"debconf/priority=critical ",
"keyboard-configuration/modelcode=pc105 keyboard-configuration/layout=FR ",
"keyboard-configuration/variant=FR console-setup/ask_detect=false ",
"net.ifnames=0 ",
"hostname={{ .Name }} ",
"passwd/user-fullname={{user `user`}} ",
"passwd/user-password-again={{user `password`}} ",
"passwd/user-password={{user `password`}} ",
"passwd/username={{user `user`}} ",
"noapic ",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed-ubuntu20.04.cfg ",
"-- <enter>"
]
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo '{{user `password`}}' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update-ubuntu.sh",
"scripts/grub-ubuntu.sh",
"{{ user `custom_script` }}"
]
}
]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment