summaryrefslogtreecommitdiff
path: root/roles/install-cloud-init
diff options
context:
space:
mode:
authorYuya Kusakabe <yuya.kusakabe@gmail.com>2018-10-25 15:51:11 +0900
committerYuya Kusakabe <yuya.kusakabe@gmail.com>2018-10-25 15:51:11 +0900
commit00a5684ba31ed5c68d168290fb45a35bf5d58177 (patch)
treeb47922585261b1090242b6dd33a9f97720bba93d /roles/install-cloud-init
parent33f18761adb0fb473865fcb1bac65df4ed2c910f (diff)
downloadvyos-vm-images-00a5684ba31ed5c68d168290fb45a35bf5d58177.tar.gz
vyos-vm-images-00a5684ba31ed5c68d168290fb45a35bf5d58177.zip
Add cloud-init to QEMU/VMware/Hyper-V imagesmaster
Diffstat (limited to 'roles/install-cloud-init')
-rw-r--r--roles/install-cloud-init/files/debian.list7
-rw-r--r--roles/install-cloud-init/files/hyper-v.cfg1
-rw-r--r--roles/install-cloud-init/files/qemu.cfg1
-rw-r--r--roles/install-cloud-init/files/vmware.cfg1
-rw-r--r--roles/install-cloud-init/tasks/main.yml33
-rw-r--r--roles/install-cloud-init/tests/inventory2
-rw-r--r--roles/install-cloud-init/tests/test.yml4
7 files changed, 49 insertions, 0 deletions
diff --git a/roles/install-cloud-init/files/debian.list b/roles/install-cloud-init/files/debian.list
new file mode 100644
index 0000000..f657759
--- /dev/null
+++ b/roles/install-cloud-init/files/debian.list
@@ -0,0 +1,7 @@
+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://deb.debian.org/debian jessie-backports main
diff --git a/roles/install-cloud-init/files/hyper-v.cfg b/roles/install-cloud-init/files/hyper-v.cfg
new file mode 100644
index 0000000..f66d7c0
--- /dev/null
+++ b/roles/install-cloud-init/files/hyper-v.cfg
@@ -0,0 +1 @@
+datasource_list: [ NoCloud, ConfigDrive, None ]
diff --git a/roles/install-cloud-init/files/qemu.cfg b/roles/install-cloud-init/files/qemu.cfg
new file mode 100644
index 0000000..f66d7c0
--- /dev/null
+++ b/roles/install-cloud-init/files/qemu.cfg
@@ -0,0 +1 @@
+datasource_list: [ NoCloud, ConfigDrive, None ]
diff --git a/roles/install-cloud-init/files/vmware.cfg b/roles/install-cloud-init/files/vmware.cfg
new file mode 100644
index 0000000..76a5efd
--- /dev/null
+++ b/roles/install-cloud-init/files/vmware.cfg
@@ -0,0 +1 @@
+datasource_list: [ NoCloud, ConfigDrive, OVF, None ]
diff --git a/roles/install-cloud-init/tasks/main.yml b/roles/install-cloud-init/tasks/main.yml
new file mode 100644
index 0000000..c9d5d07
--- /dev/null
+++ b/roles/install-cloud-init/tasks/main.yml
@@ -0,0 +1,33 @@
+- name: Put debian.list
+ become: true
+ copy:
+ src: files/debian.list
+ dest: "{{ vyos_install_root }}/etc/apt/sources.list.d/debian.list"
+- name: apt-get update
+ become: true
+ command: chroot {{ vyos_install_root }} apt-get update
+- name: Install cloud-init
+ become: true
+ command: chroot {{ vyos_install_root }} apt-get install -y cloud-init cloud-utils
+- name: apt-get clean
+ become: true
+ command: chroot {{ vyos_install_root }} apt-get clean
+- name: Delete debian.list
+ become: true
+ file:
+ path: "{{ vyos_install_root }}/etc/apt/sources.list.d/debian.list"
+ state: absent
+- name: Create cfg.d dir
+ become: true
+ file:
+ path: "{{ vyos_install_root }}/etc/cloud/cloud.cfg.d/"
+ state: directory
+ mode: 0755
+- name: Put datasource_list.cfg
+ become: true
+ copy:
+ src: "files/{{ vyos_platform | lower }}.cfg"
+ dest: "{{ vyos_install_root }}/etc/cloud/cloud.cfg.d/90_dpkg.cfg"
+- name: run dpkg-reconfigure cloud-init
+ become: true
+ command: chroot {{ vyos_install_root }} dpkg-reconfigure -f noninteractive cloud-init
diff --git a/roles/install-cloud-init/tests/inventory b/roles/install-cloud-init/tests/inventory
new file mode 100644
index 0000000..878877b
--- /dev/null
+++ b/roles/install-cloud-init/tests/inventory
@@ -0,0 +1,2 @@
+localhost
+
diff --git a/roles/install-cloud-init/tests/test.yml b/roles/install-cloud-init/tests/test.yml
new file mode 100644
index 0000000..7bf7a19
--- /dev/null
+++ b/roles/install-cloud-init/tests/test.yml
@@ -0,0 +1,4 @@
+---
+- hosts: localhost
+ roles:
+ - install-cloud-init