]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
cobbler_profile: add the ability to set kernel options.
authorAndrew Schoen <aschoen@redhat.com>
Wed, 20 May 2015 19:10:28 +0000 (14:10 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Wed, 20 May 2015 21:18:21 +0000 (16:18 -0500)
We can now provide custom kernel_options and kernel_options_post when
creating a profile. Updating the kernel_options are not idempotent
however as some kernel options are always return from the distro.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
roles/cobbler_profile/defaults/main.yml
roles/cobbler_profile/tasks/import_distro.yml
roles/cobbler_profile/tasks/update_kernel_options.yml [new file with mode: 0644]
roles/cobbler_profile/tasks/update_kernel_options_post.yml [new file with mode: 0644]

index a78bdfaedcf0aed23f91e1a09392d7b3d183701c..a5146dffd75cd0b59cbcb650cf5530502b159a6e 100644 (file)
@@ -18,9 +18,15 @@ distros:
   "Ubuntu-12.04-server-x86_64":
       iso: "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso"
       kickstart: cephlab_ubuntu.preseed
+      kernel_options: "netcfg/choose_interface=auto biosdevname=0 console=tty0 console=ttyS1,115200"
+      kernel_options_post: "pci=realloc=off console=tty0 console=ttyS1,115200"
   "Ubuntu-14.04-server-x86_64":
       iso: "http://releases.ubuntu.com/14.04/ubuntu-14.04.2-server-amd64.iso"
       kickstart: cephlab_ubuntu.preseed
+      kernel_options: "netcfg/choose_interface=auto biosdevname=0 console=tty0 console=ttyS1,115200"
+      kernel_options_post: "pci=realloc=off console=tty0 console=ttyS1,115200"
   "Ubuntu-15.04-server-x86_64":
       iso: "http://releases.ubuntu.com/15.04/ubuntu-15.04-server-amd64.iso"
       kickstart: cephlab_ubuntu.preseed
+      kernel_options: "netcfg/choose_interface=auto biosdevname=0 console=tty0 console=ttyS1,115200"
+      kernel_options_post: "pci=realloc=off console=tty0 console=ttyS1,115200"
index f683b399b7ca6a1a4d72258405e2e9147c5e9ede..fc0027c87ccf568568191ca6d9def0764d4d4e60 100644 (file)
          (import is defined and import.rc == 0))
 
 - include: update_kickstart.yml
-  when: distro.kickstart is defined and distro.kickstart != '' and
+  when: distro.kickstart is defined and
+        distro.kickstart != '' and
+        profile_found
+
+- include: update_kernel_options.yml
+  when: distro.kernel_options is defined and
+        distro.kernel_options != '' and
+        profile_found
+
+- include: update_kernel_options_post.yml
+  when: distro.kernel_options_post is defined and
+        distro.kernel_options_post != '' and
         profile_found
diff --git a/roles/cobbler_profile/tasks/update_kernel_options.yml b/roles/cobbler_profile/tasks/update_kernel_options.yml
new file mode 100644 (file)
index 0000000..37914e8
--- /dev/null
@@ -0,0 +1,15 @@
+---
+# This returns additional kernel_options not explicitly set in the profile by us.
+# These values come from the distro import, I believe. Here's some example output from the vivid profile:
+# ksdevice=bootif lang=  biosdevname=0 text netcfg/choose_interface=auto console=tty0 console=ttyS1,115200
+# The 'ksdevice=bootif lang=' was not added by the profile and persists even when resetting the kernel_options
+# in the next task. This means that setting kernel_options will never be idempotent.
+- name: Check to see if kernel_options needs updating
+  shell: "cobbler profile dumpvars --name={{ distro_name }} | grep '^kernel_options :' | cut -d : -f 2" 
+  changed_when: false
+  register: kernel_options
+
+# This task is not idempotent because of the reason mentioned above.
+- name: "Set the profile's kernel_options"
+  command: cobbler profile edit --name={{ distro_name }} --kopts='{{ distro.kernel_options }}'
+  when: kernel_options.stdout.strip() != distro.kernel_options
diff --git a/roles/cobbler_profile/tasks/update_kernel_options_post.yml b/roles/cobbler_profile/tasks/update_kernel_options_post.yml
new file mode 100644 (file)
index 0000000..ede37d2
--- /dev/null
@@ -0,0 +1,9 @@
+---
+- name: Get current value for kernel_options_post
+  shell: "cobbler profile dumpvars --name={{ distro_name }} | grep '^kernel_options_post :' | cut -d : -f 2"
+  changed_when: false
+  register: kernel_options_post
+
+- name: "Set the profile's kernel_options_post if needed."
+  command: cobbler profile edit --name={{ distro_name }} --kopts-post='{{ distro.kernel_options_post }}'
+  when: kernel_options_post.stdout.strip() != distro.kernel_options_post