From 195245b98e5c0657cb7a2ff11ca506df3a671682 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Mon, 16 Mar 2015 12:28:42 -0400 Subject: [PATCH] Cleanup required for deploy role changes to function Moved template file locations to the correct role. Corrected syntax error in deploy.yaml. Removed "templates/" path from template entires as it is not required when using a role. Added fact collection into roles where required as passing vars between roles does not seem clean nor maintainable in the long run. --- deploy.yaml | 2 +- roles/bifrost-configdrives/tasks/main.yml | 14 +++++++++++--- .../templates/interfaces.j2 | 0 .../templates/openstack_meta_data.json.j2 | 0 roles/bifrost-setup-nodes/tasks/main.yml | 3 +++ 5 files changed, 15 insertions(+), 4 deletions(-) rename roles/{ironic-deploy => bifrost-configdrives}/templates/interfaces.j2 (100%) rename roles/{ironic-deploy => bifrost-configdrives}/templates/openstack_meta_data.json.j2 (100%) diff --git a/deploy.yaml b/deploy.yaml index 36af6f8c4..0ee75f664 100644 --- a/deploy.yaml +++ b/deploy.yaml @@ -4,7 +4,7 @@ name: "Enroll hardware from baremetal.csv into Ironic" sudo: yes gather_facts: yes - pre-tasks: + pre_tasks: - name: "Error if variable baremetal_csv_file is not defined" local_action: fail msg="baremetal_csv_file must be defined for this playbook to execute, please pass option '-e baremetal_csv_file='" when: baremetal_csv_file is not defined diff --git a/roles/bifrost-configdrives/tasks/main.yml b/roles/bifrost-configdrives/tasks/main.yml index 946962abc..016b3e835 100644 --- a/roles/bifrost-configdrives/tasks/main.yml +++ b/roles/bifrost-configdrives/tasks/main.yml @@ -12,6 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. --- +- name: "Check to see if there is a file where the ssh_key_path is defined" + local_action: stat path={{ ssh_public_key_path }} + register: test_ssh_public_key_path +- name: "Error if ssh_public_key_path is not valid" + local_action: fail msg="ssh_public_key_path is not valid." + when: test_ssh_public_key_path.stat.exists == false +- name: "Read ssh public key in" + local_action: set_fact ssh_public_key="{{ lookup('file', ssh_public_key_path ) }}" - name: "Name Make Temporary folder to build configdrive" local_action: command mktemp -d register: variable_configdrive_location @@ -24,11 +32,11 @@ with_lines: - cat {{ baremetal_csv_file }} - name: "Place template in each openstack/2012-08-10 folder" - local_action: template src=templates/openstack_meta_data.json.j2 dest={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/2012-08-10/meta_data.json + local_action: template src=openstack_meta_data.json.j2 dest={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/2012-08-10/meta_data.json with_lines: - cat {{ baremetal_csv_file }} - name: "Place template in each openstack/latest folder" - local_action: template src=templates/openstack_meta_data.json.j2 dest={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/latest/meta_data.json + local_action: template src=openstack_meta_data.json.j2 dest={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/latest/meta_data.json with_lines: - cat {{ baremetal_csv_file }} - name: "Make Metadata folder - /openstack/latest" @@ -36,7 +44,7 @@ with_lines: - cat {{ baremetal_csv_file }} - name: "Write network interface template" - local_action: template src=templates/interfaces.j2 dest={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/content/0000 + local_action: template src=interfaces.j2 dest={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/content/0000 with_lines: - cat {{ baremetal_csv_file }} - name: "Make config drive files" diff --git a/roles/ironic-deploy/templates/interfaces.j2 b/roles/bifrost-configdrives/templates/interfaces.j2 similarity index 100% rename from roles/ironic-deploy/templates/interfaces.j2 rename to roles/bifrost-configdrives/templates/interfaces.j2 diff --git a/roles/ironic-deploy/templates/openstack_meta_data.json.j2 b/roles/bifrost-configdrives/templates/openstack_meta_data.json.j2 similarity index 100% rename from roles/ironic-deploy/templates/openstack_meta_data.json.j2 rename to roles/bifrost-configdrives/templates/openstack_meta_data.json.j2 diff --git a/roles/bifrost-setup-nodes/tasks/main.yml b/roles/bifrost-setup-nodes/tasks/main.yml index 3240b51f3..fa4ac10b8 100644 --- a/roles/bifrost-setup-nodes/tasks/main.yml +++ b/roles/bifrost-setup-nodes/tasks/main.yml @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. --- +- name: "Collect the checksum of the deployment image." + local_action: stat path={{deploy_image}} + register: test_deploy_image - name: "Deploy to Hardware" # TODO: Conceptual idea of structure, needs image_source corrected and # disk format clarified