summaryrefslogtreecommitdiff
path: root/roles/install-custom-packages/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/install-custom-packages/tasks/main.yml')
-rw-r--r--roles/install-custom-packages/tasks/main.yml60
1 files changed, 60 insertions, 0 deletions
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