diff --git a/roles/config_drive/tasks/main.yml b/roles/config_drive/tasks/main.yml index 692391b2f5..1651c7a2a8 100644 --- a/roles/config_drive/tasks/main.yml +++ b/roles/config_drive/tasks/main.yml @@ -49,6 +49,9 @@ - name: Generate user-data register: _user_data_change + when: + - cifmw_config_drive_userdata is defined + - cifmw_config_drive_userdata | length > 0 ansible.builtin.template: src: "user-data.j2" dest: "{{ cifmw_config_drive_instancedir }}/user-data" @@ -57,8 +60,8 @@ - name: Generate network-data register: _net_data_change when: - - "cifmw_config_drive_networkconfig is defined" - - "cifmw_config_drive_networkconfig is not none" + - cifmw_config_drive_networkconfig is defined + - cifmw_config_drive_networkconfig | length > 0 ansible.builtin.template: src: "network-config.j2" dest: "{{ cifmw_config_drive_instancedir }}/network-config" @@ -95,6 +98,6 @@ -joliet -rock user-data meta-data {% if cifmw_config_drive_networkconfig is defined and - cifmw_config_drive_networkconfig is not none -%} + cifmw_config_drive_networkconfig | length > 0 -%} network-config {%- endif -%} diff --git a/roles/config_drive/templates/user-data.j2 b/roles/config_drive/templates/user-data.j2 index a50c3d6033..cbe9a15795 100644 --- a/roles/config_drive/templates/user-data.j2 +++ b/roles/config_drive/templates/user-data.j2 @@ -1,4 +1,2 @@ #cloud-config -{% if cifmw_config_drive_userdata is defined and cifmw_config_drive_userdata is not none -%} {{ cifmw_config_drive_userdata | to_nice_yaml(indent=2) }} -{% endif %}