val
March 21, 2023, 3:18pm
#1
Problem:
ERROR! the role ‘theforeman.foreman.os_default_template’ was not found in “…”
The error appears to be in ‘… tasks/setup.yml’: line 164, column 18, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
ansible.builtin.include_role:
name: theforeman.foreman.os_default_template
^ here
Expected outcome:
a working role !
Foreman and Proxy versions:
foreman 3.5.2
ansible collection 3.9.0
Distribution and version:
RHEL 8.7
evgeni
March 21, 2023, 3:24pm
#2
val
March 21, 2023, 3:31pm
#3
what’s the difference for you between role and module ?
val
March 21, 2023, 3:48pm
#5
what is confusing, is that some are role, some are module, some are both in the collection…
what differentiate the usage in foreman context ?
evgeni
March 21, 2023, 3:52pm
#6
there are no modules with the same name as the role
what there is, sometimes, that there is a role with a simimlar name to a module, where the module is called e.g. content_view
(singular) and the role content_views
(plural).
depending on your usecase, you might want to manage multiple entities of the same type and then such a role might be useful
val
March 21, 2023, 4:09pm
#7
for now, trying to do that :
- name: Create a Provisioning Template
ansible.builtin.include_role:
name: theforeman.foreman.provisioning_templates
vars:
foreman_server_url: https://10.34.58.90/
foreman_username: admin
foreman_password: admin
foreman_validate_certs: false
foreman_provisioning_template:
foreman_provisioning_templates:
- name: WL-RH8-kickstart_test
kind: provision
state: absent
organizations: "WL-GLOBAL"
- name: WL-RH8-kickstart
kind: provision
file_name: "/var/tmp/provision/WL-RH8-kickstart"
state: present
organizations: "WL-GLOBAL"
- name: "WL-RH8-kickstart custom post"
kind: snippet
file_name: "/var/tmp/snippet/WL-RH8-kickstart-custom-post"
state: present
organizations: "WL-GLOBAL"
- name: WL-RH8-PXE
kind: PXELinux
file_name: "/var/tmp/PXELinux/WL-RH8-PXE"
state: present
organizations: "WL-GLOBAL"
- name: Create an OS
ansible.builtin.include_role:
name: theforeman.foreman.operatingsystems
vars:
foreman_server_url: https://10.34.58.90/
foreman_username: admin
foreman_password: admin
foreman_validate_certs: false
foreman_provisioning_template:
foreman_operatingsystems:
- name: "WL-RHEL"
major: "8"
minor: "7"
os_family: "Redhat"
password_hash: "SHA256"
architectures: "x86_64"
default_templates:
- template_kind: "provision"
provisioning_template: "WL-RH8-kickstart"
- template_kind: "PXELinux"
provisioning_template: "WL-RH8-PXE"
- name: "Create an kickstart Association"
theforeman.foreman.os_default_template:
server_url: https://10.34.58.90/
username: admin
password: admin
validate_certs: false
provisioning_template:
operatingsystem: "WL-RHEL 8.7"
template_kind: "provision"
provisioning_template: "WL-RH8-kickstart"
state: present
the last one, “association” doesn’t work…
What did I do wrong then ?
did I miss some info ?
val
March 21, 2023, 4:16pm
#9
no error is return, but no association seems to be done…
when looking at template “WL-RH8-kickstart”, in the “Association” tab,
in “all items”, I see “RHEL 8.7, WL RHEL 8.7”, but in “Selected”: empty.
evgeni
March 21, 2023, 5:48pm
#10
Ah, look! You have the provisioning_template
parameter twice, and the first one wins:
- name: "Create an kickstart Association"
theforeman.foreman.os_default_template:
server_url: https://10.34.58.90/
username: admin
password: admin
validate_certs: false
provisioning_template: <<<
operatingsystem: "WL-RHEL 8.7"
template_kind: "provision"
provisioning_template: "WL-RH8-kickstart" <<<
state: present
I would have expected Ansible to have complained about that tho, like this?
[WARNING]: While constructing a mapping from /tmp/l.yml, line 6, column 9, found a duplicate dict key (provisioning_template). Using last defined value only.