summaryrefslogtreecommitdiff
path: root/roles/install-guest-agent
diff options
context:
space:
mode:
Diffstat (limited to 'roles/install-guest-agent')
-rw-r--r--roles/install-guest-agent/files/debian.list.buster4
-rw-r--r--roles/install-guest-agent/files/debian.list.jessie5
-rw-r--r--roles/install-guest-agent/files/resolv.conf1
-rw-r--r--roles/install-guest-agent/tasks/main.yml46
-rw-r--r--roles/install-guest-agent/tests/inventory2
-rw-r--r--roles/install-guest-agent/tests/test.yml4
6 files changed, 62 insertions, 0 deletions
diff --git a/roles/install-guest-agent/files/debian.list.buster b/roles/install-guest-agent/files/debian.list.buster
new file mode 100644
index 0000000..4950c4e
--- /dev/null
+++ b/roles/install-guest-agent/files/debian.list.buster
@@ -0,0 +1,4 @@
+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
new file mode 100644
index 0000000..885e26b
--- /dev/null
+++ b/roles/install-guest-agent/files/debian.list.jessie
@@ -0,0 +1,5 @@
+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
new file mode 100644
index 0000000..81027f8
--- /dev/null
+++ b/roles/install-guest-agent/files/resolv.conf
@@ -0,0 +1 @@
+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
new file mode 100644
index 0000000..f636f53
--- /dev/null
+++ b/roles/install-guest-agent/tasks/main.yml
@@ -0,0 +1,46 @@
+- 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: Put debian.list
+ become: true
+ copy:
+ src: "files/debian.list.{{ debian_version.stdout }}"
+ 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: Install qemu-guest-agent
+ become: true
+ command: chroot {{ vyos_install_root }} apt-get -t {{ vyos_branch | default('current') }} install -y qemu-guest-agent
+ when: guest_agent == "qemu"
+- name: Install open-vm-tools
+ become: true
+ command: chroot {{ vyos_install_root }} apt-get -t {{ vyos_branch | default('current') }} install -y open-vm-tools
+ when: guest_agent == "vmware"
+- 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-guest-agent/tests/inventory b/roles/install-guest-agent/tests/inventory
new file mode 100644
index 0000000..878877b
--- /dev/null
+++ b/roles/install-guest-agent/tests/inventory
@@ -0,0 +1,2 @@
+localhost
+
diff --git a/roles/install-guest-agent/tests/test.yml b/roles/install-guest-agent/tests/test.yml
new file mode 100644
index 0000000..79b8c2d
--- /dev/null
+++ b/roles/install-guest-agent/tests/test.yml
@@ -0,0 +1,4 @@
+---
+- hosts: localhost
+ roles:
+ - install-guest-agent