- name: Install cloud-init ansible.builtin.dnf: name: - cloud-init - cloud-utils-growpart - dracut-config-generic state: present - name: Enable cloud-init services ansible.builtin.service: name: "{{ item }}" enabled: true with_items: - cloud-config - cloud-init - cloud-init-local - cloud-final - name: Configure cloud-init user name ansible.builtin.replace: dest: /etc/cloud/cloud.cfg regexp: '^(\s+name:).*$' replace: "\\1 {{ cloud_init_user }}" when: cloud_init_user | length > 0