Feature: Enable user_data's file generation

This feature allow custom user-data's file generation by the user.
It is usefull for example when user needs to set up an advanced ssh configuration (special user, SSH certificate-based authentication)

Signed-off-by: vguillard <vincent.guillard@b-com.com>
Story: 2010475
Task: 47036
Change-Id: I2831e58d84f1da03485f8315eccdd2e79231e584
This commit is contained in:
vguillard 2023-01-12 16:23:01 +01:00
parent f06b8a7580
commit bf1bb49c38
4 changed files with 39 additions and 0 deletions

View File

@ -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:

View File

@ -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

View File

@ -0,0 +1,3 @@
#cloud-config
{{ user_data_content }}

View File

@ -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: <HASH_OF_MY_PASSWORD>
lock_passwd: false
timezone: "Europe/Paris"