bifrost/roles/bifrost-configdrives/tasks/main.yml
Julia Kreger 5598f3baa7 Change configdrive steps to use sudo
Changed the configdrive generation steps to utilize sudo so the base
user context remains the same as the running user the playbook
and thus the user's key can be incorporated without needing root
privliges

This is part of issue #5
2015-03-23 18:24:13 -04:00

68 lines
3.5 KiB
YAML

# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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
- name: "Make Metadata folder - /openstack/2012-08-10"
local_action: file state=directory name={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/2012-08-10/
with_lines:
- cat {{ baremetal_csv_file }}
- name: "Make Metadata folder - /openstack/latest"
local_action: file state=directory name={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/latest/
with_lines:
- cat {{ baremetal_csv_file }}
- name: "Place template in each openstack/2012-08-10 folder"
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=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"
local_action: file state=directory name={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/content/
with_lines:
- cat {{ baremetal_csv_file }}
- name: "Write network interface template"
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"
sudo: yes
local_action: command mkisofs -R -V config-2 -o {{http_boot_folder}}/configdrive-{{item.split(',')[9]}}.iso {{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}
with_lines:
- cat {{ baremetal_csv_file }}
- name: "Make config drive files base64 encoded and gzip compressed"
sudo: yes
local_action: shell gzip -c {{http_boot_folder}}/configdrive-{{item.split(',')[9]}}.iso | base64 > {{http_boot_folder}}/configdrive-{{item.split(',')[9]}}.iso.gz
with_lines:
- cat {{ baremetal_csv_file }}
- name: "Cleanup configdrive .iso files"
sudo: yes
local_action: file state=absent name={{http_boot_folder}}/configdrive-{{item.split(',')[9]}}.iso
with_lines:
- cat {{ baremetal_csv_file }}
- name: "Cleanup configdrive temp folder"
sudo: yes
local_action: file state=absent force=yes name={{ variable_configdrive_location.stdout }}