From: Andrew Schoen Date: Tue, 19 May 2015 20:50:00 +0000 (-0500) Subject: cobbler_profile: move kickstart updating tasks into their own yml file. X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b2043010d2657af693586549460d87d0001a813b;p=ceph-cm-ansible.git cobbler_profile: move kickstart updating tasks into their own yml file. This also introduce a var, profile_found, which we can reuse for updating other parts of a profile like kernel options. Signed-off-by: Andrew Schoen --- diff --git a/roles/cobbler_profile/tasks/import_distro.yml b/roles/cobbler_profile/tasks/import_distro.yml index 7300a4a..f683b39 100644 --- a/roles/cobbler_profile/tasks/import_distro.yml +++ b/roles/cobbler_profile/tasks/import_distro.yml @@ -71,21 +71,14 @@ state: unmounted when: mount is defined and mount|changed -- name: Set kickstart path +# If either the profile already existed or we successfully imported the +# distro, we might want to update other options in the profile. i.e. kickstarts +- name: Set profile_found set_fact: - kickstart_path: /var/lib/cobbler/kickstarts/{{ distro.kickstart }} - # If either the profile already existed or we successfully imported the - # distro, let's see if we need to change the kickstart. - when: distro.kickstart is defined and distro.kickstart != '' and + profile_found: ((profile is defined and profile.stdout == distro_name) or (import is defined and import.rc == 0)) -- name: Check to see if the kickstart needs updating - shell: cobbler profile dumpvars --name={{ distro_name }} | grep '^kickstart :' | awk '{ print $3 }' - when: kickstart_path is defined - changed_when: false - register: kickstart - -- name: "Set the profile's kickstart" - command: cobbler profile edit --name={{ distro_name }} --kickstart={{ kickstart_path }} - when: kickstart is defined and kickstart.stdout != kickstart_path +- include: update_kickstart.yml + when: distro.kickstart is defined and distro.kickstart != '' and + profile_found diff --git a/roles/cobbler_profile/tasks/update_kickstart.yml b/roles/cobbler_profile/tasks/update_kickstart.yml new file mode 100644 index 0000000..9ad469a --- /dev/null +++ b/roles/cobbler_profile/tasks/update_kickstart.yml @@ -0,0 +1,15 @@ +--- +- name: Set kickstart path + set_fact: + kickstart_path: /var/lib/cobbler/kickstarts/{{ distro.kickstart }} + +- name: Check to see if the kickstart needs updating + shell: cobbler profile dumpvars --name={{ distro_name }} | grep '^kickstart :' | awk '{ print $3 }' + when: kickstart_path is defined + changed_when: false + register: kickstart + +- name: "Set the profile's kickstart" + command: cobbler profile edit --name={{ distro_name }} --kickstart={{ kickstart_path }} + when: kickstart is defined and + kickstart.stdout != kickstart_path