diff --git a/playbooks/roles/bifrost-configdrives-dynamic/defaults/main.yml b/playbooks/roles/bifrost-configdrives-dynamic/defaults/main.yml index a77b3c966..595b9af61 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/defaults/main.yml +++ b/playbooks/roles/bifrost-configdrives-dynamic/defaults/main.yml @@ -32,3 +32,12 @@ iso_gen_utility: "mkisofs" # Ensure that Ansible is using python interpreter and dependencies inside the bifrost virtual environment bifrost_venv_dir: "{{ lookup('env', 'VENV') or '/opt/stack/bifrost' }}" ansible_python_interpreter: "{{ bifrost_venv_dir + '/bin/python3' }}" + +# Define your user-data's script here (cloud-config syntax) +# For example: +# user_data_content: | +# users: +# name: myuser +# +# timezone: "Europe/Paris" ++user_data_content: diff --git a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml index e317264c3..9f78a032e 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml @@ -83,6 +83,16 @@ when: - addressing_mode is undefined or "dhcp" not in addressing_mode +- name: "Generate user_data" + template: + src: raw_user_data.j2 + dest: "{{ variable_configdrive_location.path }}/{{ uuid }}/openstack/{{ item }}/user_data" + loop: "{{ metadata_versions }}" + when: + - user_data_content is defined + - user_data_content | length > 0 + + - name: "Make metadata folder - /openstack/content" file: state: directory diff --git a/playbooks/roles/bifrost-configdrives-dynamic/templates/raw_user_data.j2 b/playbooks/roles/bifrost-configdrives-dynamic/templates/raw_user_data.j2 new file mode 100644 index 000000000..f407baab6 --- /dev/null +++ b/playbooks/roles/bifrost-configdrives-dynamic/templates/raw_user_data.j2 @@ -0,0 +1,3 @@ +#cloud-config + +{{ user_data_content }} diff --git a/releasenotes/notes/create-cloud-config-e4e15a422bc04adf.yaml b/releasenotes/notes/create-cloud-config-e4e15a422bc04adf.yaml new file mode 100644 index 000000000..2f6128707 --- /dev/null +++ b/releasenotes/notes/create-cloud-config-e4e15a422bc04adf.yaml @@ -0,0 +1,17 @@ +--- +features: + - | + bifrost introduce now the ``user_data content`` variable + which allows to the user to provide its custom cloud-config file + For example: + .. code-block:: yaml + + user_data_content: | + users: + name: myuser + sudo: ALL=(ALL) NOPASSWD:ALL + shell: /bin/bash + passwd: + lock_passwd: false + + timezone: "Europe/Paris"