diff options
23 files changed, 123 insertions, 59 deletions
@@ -121,14 +121,19 @@ You need to copy the ISO image with VyOS to /tmp/vyos.iso before running ansible -e keep_user=true ``` -- Create an image with empty configuration, do not add any default settings like eth0 address, SSH service (default: false): +- Select a type of partition table for a disk image. Supported: `mbr`, `gpt`, `hybrid` (default: `hybrid`): ``` - -e empty_config=true + -e parttable_type=hybrid ``` - -- Select a type of partition table for a disk image. Supported: `mbr`, `gpt`, `hybrid` (default: `hybrid`): +- Select default console for boot. Supported: `kvm`, `serial` (default: depending on platform): ``` - -e parttable_type=hybrid + -e grub_console=serial + ``` + +- Install custom packages. Can be a list in the `files/custom_packages_list.txt` file separated by spaces, or deb files inside the `files/custom_debs/` directory: + ``` + -e custom_packages=true + ```
\ No newline at end of file diff --git a/files/custom_packages_list.txt b/files/custom_packages_list.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/files/custom_packages_list.txt diff --git a/roles/install-cloud-init/files/resolv.conf b/files/resolv.conf index 81027f8..81027f8 100644 --- a/roles/install-cloud-init/files/resolv.conf +++ b/files/resolv.conf @@ -25,6 +25,7 @@ - install-persistence-conf - install-cloud-init-wrapper - install-guest-agent-wrapper + - install-custom-packages-wrapper - fstrim - unmount-pre - create-pxe-archive diff --git a/roles/fstrim/tasks/main.yml b/roles/fstrim/tasks/main.yml index e7230a7..c0b9b19 100644 --- a/roles/fstrim/tasks/main.yml +++ b/roles/fstrim/tasks/main.yml @@ -1,8 +1,4 @@ # Trim filesystems to minimize resulted image -- name: Trim {{ vyos_install_root }}/boot - become: true - command: fstrim {{ vyos_install_root }}/boot - - name: Trim {{ vyos_write_root }} become: true command: fstrim {{ vyos_write_root }} diff --git a/roles/install-cloud-init/files/debian.list.buster b/roles/install-cloud-init/files/debian.list.buster deleted file mode 100644 index fd5a770..0000000 --- a/roles/install-cloud-init/files/debian.list.buster +++ /dev/null @@ -1,7 +0,0 @@ -deb http://deb.debian.org/debian buster main contrib non-free -deb-src http://deb.debian.org/debian buster main contrib non-free -deb http://security.debian.org/debian-security/ buster/updates main contrib non-free -deb-src http://security.debian.org/debian-security/ buster/updates main contrib non-free -deb http://deb.debian.org/debian buster-updates main contrib non-free -deb-src http://deb.debian.org/debian buster-updates main contrib non-free -deb http://dev.packages.vyos.net/repositories/current current main diff --git a/roles/install-cloud-init/files/debian.list.jessie b/roles/install-cloud-init/files/debian.list.jessie deleted file mode 100644 index 0750699..0000000 --- a/roles/install-cloud-init/files/debian.list.jessie +++ /dev/null @@ -1,8 +0,0 @@ -deb http://deb.debian.org/debian jessie main contrib non-free -deb-src http://deb.debian.org/debian jessie main contrib non-free -deb http://security.debian.org/debian-security/ jessie/updates main contrib non-free -deb-src http://security.debian.org/debian-security/ jessie/updates main contrib non-free -deb http://deb.debian.org/debian jessie-updates main contrib non-free -deb-src http://deb.debian.org/debian jessie-updates main contrib non-free -deb http://dev.packages.vyos.net/repositories/crux/vyos crux main -deb http://dev.packages.vyos.net/repositories/crux/debian crux main diff --git a/roles/install-cloud-init/tasks/main.yml b/roles/install-cloud-init/tasks/main.yml index 2ae314b..ae6f67b 100644 --- a/roles/install-cloud-init/tasks/main.yml +++ b/roles/install-cloud-init/tasks/main.yml @@ -6,10 +6,14 @@ set_fact: vyos_branch: "crux" when: vyos_version is regex("^1\.2.*$") +- name: Set VyOS branch name equuleus + set_fact: + vyos_branch: "equuleus" + when: vyos_version is regex("^1\.3.*$") - name: Put debian.list become: true - copy: - src: "files/debian.list.{{ debian_version.stdout }}" + template: + src: "templates/debian.list.j2" dest: "{{ vyos_install_root }}/etc/apt/sources.list.d/debian.list" - name: backup resolv.conf become: true @@ -61,7 +65,3 @@ - name: restore original resolv.conf become: true command: mv /tmp/resolv.conf {{ vyos_install_root }}/etc/resolv.conf -- name: change /etc/network/interfaces to include config from Cloud-Init - become: true - command: chroot {{ vyos_install_root }} sed -i 's/source-directory \/etc\/network\/interfaces.d/source \/etc\/network\/interfaces.d\/*/g' /etc/network/interfaces - when: vyos_version is regex("^1\.2.*$") diff --git a/roles/install-config/templates/config.boot.j2 b/roles/install-config/templates/config.boot.j2 index 30506f8..852905e 100644 --- a/roles/install-config/templates/config.boot.j2 +++ b/roles/install-config/templates/config.boot.j2 @@ -10,7 +10,9 @@ system { {% endif %} plaintext-password "" } +{% if vyos_version | regex_search('(^1\.2)') %} level admin +{% endif %} } } syslog { @@ -33,18 +35,6 @@ system { } } interfaces { -{% if cloud_init == "true" and not ( empty_config is defined and empty_config == "true" ) %} - ethernet eth0 { - address dhcp - } -{% endif %} loopback lo { } } -{% if cloud_init == "true" and not ( empty_config is defined and empty_config == "true" ) %} -service { - ssh { - port 22 - } -} -{% endif %} diff --git a/roles/install-custom-packages-wrapper/tasks/main.yml b/roles/install-custom-packages-wrapper/tasks/main.yml new file mode 100644 index 0000000..b67f73c --- /dev/null +++ b/roles/install-custom-packages-wrapper/tasks/main.yml @@ -0,0 +1,4 @@ +- name: Check if we need to install custom packages + include_role: + name: install-custom-packages + when: custom_packages is defined diff --git a/roles/install-custom-packages-wrapper/tests/inventory b/roles/install-custom-packages-wrapper/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/install-custom-packages-wrapper/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/install-custom-packages-wrapper/tests/test.yml b/roles/install-custom-packages-wrapper/tests/test.yml new file mode 100644 index 0000000..085b15c --- /dev/null +++ b/roles/install-custom-packages-wrapper/tests/test.yml @@ -0,0 +1,4 @@ +--- +- hosts: localhost + roles: + - install-custom-packages-wrapper diff --git a/roles/install-custom-packages/tasks/main.yml b/roles/install-custom-packages/tasks/main.yml new file mode 100644 index 0000000..1d8cd47 --- /dev/null +++ b/roles/install-custom-packages/tasks/main.yml @@ -0,0 +1,60 @@ +- name: Get Debian version + become: true + command: chroot {{ vyos_install_root }} awk 'match($0, /VERSION=.*\((\w+)\)/, version) { print version[1] }' /etc/os-release + register: debian_version +- name: Set VyOS branch name crux + set_fact: + vyos_branch: "crux" + when: vyos_version is regex("^1\.2.*$") +- name: Set VyOS branch name equuleus + set_fact: + vyos_branch: "equuleus" + when: vyos_version is regex("^1\.3.*$") +- name: Put debian.list + become: true + template: + src: "templates/debian.list.j2" + dest: "{{ vyos_install_root }}/etc/apt/sources.list.d/debian.list" +- name: backup resolv.conf + become: true + command: mv {{ vyos_install_root }}/etc/resolv.conf /tmp/resolv.conf +- name: add nameserver settings to chroot + become: true + copy: + src: "files/resolv.conf" + dest: "{{ vyos_install_root }}/etc/resolv.conf" +- name: apt-get update + become: true + command: chroot {{ vyos_install_root }} apt-get update +- name: Copy packages to a temporary directory + become: true + copy: + src: "files/custom_debs/" + dest: "{{ vyos_install_root }}/tmp/custom_debs/" +- name: Install custom packages from a list + command: chroot {{ vyos_install_root }} apt-get -t {{ vyos_branch | default('current') }} install -y --no-install-recommends {{ lookup('file', 'files/custom_packages_list.txt') }} +- name: Check if custom debs directory exists + stat: + path: "{{ vyos_install_root }}/tmp/custom_debs/" + register: custom_debs_dir +- name: Install custom packages from deb files + command: chroot {{ vyos_install_root }} dpkg -i --force-depends -R /tmp/custom_debs/ + when: custom_debs_dir.stat.exists +- name: Install missed dependencies + command: chroot {{ vyos_install_root }} apt-get -f -y install +- name: Delete DEB packages + command: chroot {{ vyos_install_root }} rm -rf /tmp/custom_debs/ +- name: apt-get clean + become: true + command: chroot {{ vyos_install_root }} apt-get clean +- name: delete apt lists from cache + become: true + command: chroot {{ vyos_install_root }} rm -rf /var/lib/apt/lists/ +- name: Delete debian.list + become: true + file: + path: "{{ vyos_install_root }}/etc/apt/sources.list.d/debian.list" + state: absent +- name: restore original resolv.conf + become: true + command: mv /tmp/resolv.conf {{ vyos_install_root }}/etc/resolv.conf diff --git a/roles/install-custom-packages/tests/inventory b/roles/install-custom-packages/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/install-custom-packages/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/install-custom-packages/tests/test.yml b/roles/install-custom-packages/tests/test.yml new file mode 100644 index 0000000..9522565 --- /dev/null +++ b/roles/install-custom-packages/tests/test.yml @@ -0,0 +1,4 @@ +--- +- hosts: localhost + roles: + - install-custom-packages diff --git a/roles/install-grub/templates/boot/grub/device.map.j2 b/roles/install-grub/templates/boot/grub/device.map.j2 deleted file mode 100644 index e14205e..0000000 --- a/roles/install-grub/templates/boot/grub/device.map.j2 +++ /dev/null @@ -1 +0,0 @@ -(hd0) /dev/sda diff --git a/roles/install-grub/templates/boot/grub/grub.cfg.j2 b/roles/install-grub/templates/boot/grub/grub.cfg.j2 index 45aec3b..e16194d 100644 --- a/roles/install-grub/templates/boot/grub/grub.cfg.j2 +++ b/roles/install-grub/templates/boot/grub/grub.cfg.j2 @@ -11,21 +11,21 @@ insmod efi_gop insmod efi_uga menuentry "VyOS {{ vyos_version }} for {{ vyos_platform }} (KVM console)" { - linux /boot/{{ vyos_version }}/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{{ vyos_version }} console=ttyS0 console=tty0 + linux /boot/{{ vyos_version }}/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{{ vyos_version }} console=tty0 initrd /boot/{{ vyos_version }}/initrd.img } menuentry "VyOS {{ vyos_version }} for {{ vyos_platform }} (Serial console)" { - linux /boot/{{ vyos_version }}/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{{ vyos_version }} console=tty0 console=ttyS0 + linux /boot/{{ vyos_version }}/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{{ vyos_version }} console=ttyS0 initrd /boot/{{ vyos_version }}/initrd.img } menuentry "VyOS {{ vyos_version }} for {{ vyos_platform }} - password reset (KVM console)" { - linux /boot/{{ vyos_version }}/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{{ vyos_version }} console=ttyS0 console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot/{{ vyos_version }}/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{{ vyos_version }} console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset initrd /boot/{{ vyos_version }}/initrd.img } menuentry "VyOS {{ vyos_version }} for {{ vyos_platform }} - password reset (Serial console)" { - linux /boot/{{ vyos_version }}/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{{ vyos_version }} console=tty0 console=ttyS0 init=/opt/vyatta/sbin/standalone_root_pw_reset + linux /boot/{{ vyos_version }}/vmlinuz boot=live rootdelay=5 noautologin net.ifnames=0 biosdevname=0 vyos-union=/boot/{{ vyos_version }} console=ttyS0 init=/opt/vyatta/sbin/standalone_root_pw_reset initrd /boot/{{ vyos_version }}/initrd.img } diff --git a/roles/install-guest-agent/files/debian.list.buster b/roles/install-guest-agent/files/debian.list.buster deleted file mode 100644 index 4950c4e..0000000 --- a/roles/install-guest-agent/files/debian.list.buster +++ /dev/null @@ -1,4 +0,0 @@ -deb http://deb.debian.org/debian buster main contrib non-free -deb http://security.debian.org/debian-security/ buster/updates main contrib non-free -deb http://deb.debian.org/debian buster-updates main contrib non-free -deb http://dev.packages.vyos.net/repositories/current current main diff --git a/roles/install-guest-agent/files/debian.list.jessie b/roles/install-guest-agent/files/debian.list.jessie deleted file mode 100644 index 885e26b..0000000 --- a/roles/install-guest-agent/files/debian.list.jessie +++ /dev/null @@ -1,5 +0,0 @@ -deb http://deb.debian.org/debian jessie main contrib non-free -deb http://security.debian.org/debian-security/ jessie/updates main contrib non-free -deb http://deb.debian.org/debian jessie-updates main contrib non-free -deb http://dev.packages.vyos.net/repositories/crux/vyos crux main -deb http://dev.packages.vyos.net/repositories/crux/debian crux main diff --git a/roles/install-guest-agent/files/resolv.conf b/roles/install-guest-agent/files/resolv.conf deleted file mode 100644 index 81027f8..0000000 --- a/roles/install-guest-agent/files/resolv.conf +++ /dev/null @@ -1 +0,0 @@ -nameserver 1.1.1.1
\ No newline at end of file diff --git a/roles/install-guest-agent/tasks/main.yml b/roles/install-guest-agent/tasks/main.yml index f636f53..3c0985c 100644 --- a/roles/install-guest-agent/tasks/main.yml +++ b/roles/install-guest-agent/tasks/main.yml @@ -6,10 +6,14 @@ set_fact: vyos_branch: "crux" when: vyos_version is regex("^1\.2.*$") +- name: Set VyOS branch name equuleus + set_fact: + vyos_branch: "equuleus" + when: vyos_version is regex("^1\.3.*$") - name: Put debian.list become: true - copy: - src: "files/debian.list.{{ debian_version.stdout }}" + template: + src: "templates/debian.list.j2" dest: "{{ vyos_install_root }}/etc/apt/sources.list.d/debian.list" - name: backup resolv.conf become: true diff --git a/roles/setup-root-partition/tasks/main.yml b/roles/setup-root-partition/tasks/main.yml index bf183f3..ff1a81b 100644 --- a/roles/setup-root-partition/tasks/main.yml +++ b/roles/setup-root-partition/tasks/main.yml @@ -70,3 +70,4 @@ src: "{{ vyos_target_drive }}p{{ partition_num_root }}" fstype: "{{ vyos_root_fstype }}" state: mounted + opts: discard diff --git a/templates/debian.list.j2 b/templates/debian.list.j2 new file mode 100644 index 0000000..7d7c3f3 --- /dev/null +++ b/templates/debian.list.j2 @@ -0,0 +1,17 @@ +{% if vyos_version | regex_search('(^1\.2)') %} +deb http://deb.debian.org/debian jessie main contrib non-free +deb http://deb.debian.org/debian jessie-updates main contrib non-free +deb http://security.debian.org/debian-security/ jessie/updates main contrib non-free +deb http://dev.packages.vyos.net/repositories/crux/vyos crux main +deb http://dev.packages.vyos.net/repositories/crux/debian crux main +{% elif vyos_version | regex_search('(^1\.3)') %} +deb http://deb.debian.org/debian buster main contrib non-free +deb http://deb.debian.org/debian buster-updates main contrib non-free +deb http://security.debian.org/debian-security/ buster/updates main contrib non-free +deb http://dev.packages.vyos.net/repositories/{{ debian_version.stdout }} {{ debian_version.stdout }} main +{% else %} +deb http://deb.debian.org/debian buster main contrib non-free +deb http://deb.debian.org/debian buster-updates main contrib non-free +deb http://security.debian.org/debian-security/ buster/updates main contrib non-free +deb http://dev.packages.vyos.net/repositories/current current main +{% endif %}
\ No newline at end of file |