diff --git a/roles/foreman_provisioning/defaults/main.yml b/roles/foreman_provisioning/defaults/main.yml index 88428bed8..1f922c293 100644 --- a/roles/foreman_provisioning/defaults/main.yml +++ b/roles/foreman_provisioning/defaults/main.yml @@ -12,3 +12,4 @@ foreman_provisioning_network: 192.168.73.0 foreman_provisioning_installer_options: [] foreman_provisioning_domain: example.com foreman_provisioning_foreman_version: "{{ foreman_repositories_version | default('nightly') }}" +foreman_provisioning_centos_medium_name: "CentOS Stream 9 mirror" diff --git a/roles/foreman_provisioning/tasks/configure_centos_9.yml b/roles/foreman_provisioning/tasks/configure_centos_9.yml index adfac4856..e444e2411 100644 --- a/roles/foreman_provisioning/tasks/configure_centos_9.yml +++ b/roles/foreman_provisioning/tasks/configure_centos_9.yml @@ -12,7 +12,7 @@ architectures: - x86_64 media: - - CentOS Stream 9 mirror + - "{{ foreman_provisioning_centos_medium_name }}" provisioning_templates: "{{ result.resources | map(attribute='name') }}" ptables: - Kickstart default diff --git a/roles/foreman_provisioning/tasks/configure_debian_12_7.yml b/roles/foreman_provisioning/tasks/configure_debian_12_7.yml new file mode 100644 index 000000000..e1e4db67a --- /dev/null +++ b/roles/foreman_provisioning/tasks/configure_debian_12_7.yml @@ -0,0 +1,30 @@ +- name: "Find all relevant templates" # noqa: args[module] + theforeman.foreman.resource_info: + resource: provisioning_templates + search: name ~ "Preseed default" or name = "Linux host_init_config default" + register: result + +- name: "Ensure Debian 12.7" # noqa: args[module] + theforeman.foreman.operatingsystem: + name: Debian + family: Debian + major: 12 + minor: 7 + release_name: bookworm + architectures: + - x86_64 + media: + - Debian mirror + provisioning_templates: "{{ result.resources | map(attribute='name') }}" + ptables: + - Preseed default + state: present + password_hash: "SHA256" + +- name: "Set default template for Debian 12.7" # noqa: args[module] + theforeman.foreman.os_default_template: + operatingsystem: "Debian 12.7" + template_kind: "{{ item.template_kind_name }}" + provisioning_template: "{{ item.name }}" + state: present + loop: "{{ result.resources | sort(attribute='name') | unique(attribute='template_kind_name') }}" diff --git a/roles/foreman_provisioning/tasks/configure_debian_9_3.yml b/roles/foreman_provisioning/tasks/configure_debian_9_3.yml deleted file mode 100644 index 9469944fd..000000000 --- a/roles/foreman_provisioning/tasks/configure_debian_9_3.yml +++ /dev/null @@ -1,36 +0,0 @@ -- name: 'create Debian 9.3' - shell: > - {{ foreman_provisioning_hammer }} os info --title "Debian 9.3" || - {{ foreman_provisioning_hammer }} os create - --name Debian --major 9 --minor 3 --release-name 'stretch' --architectures x86_64 --family 'Debian' --media 'Debian mirror' --partition-tables 'Preseed default' - -- name: 'find Debian 9.3' - shell: > - {{ foreman_provisioning_hammer }} --output json os info --name "Debian 9.3" || - {{ foreman_provisioning_hammer }} --output json os info --title "Debian 9.3" - register: foreman_provisioning_debian93_json - ignore_errors: True - -- name: 'get CentOS 9.3 info' - set_fact: - foreman_provisioning_debian93: "{{ foreman_provisioning_debian93_json.stdout|from_json }}" - -- name: 'find preseed templates' - shell: > - {{ foreman_provisioning_hammer }} --output=json template list - --search 'name ~ "Preseed default"' - register: preseed_templates_json - -- name: 'set preseed templates' - set_fact: - preseed_templates: "{{ preseed_templates_json.stdout|from_json }}" - -- name: 'associate preseed templates to Debian 9.3' - shell: > - {{ foreman_provisioning_hammer }} template add-operatingsystem --id {{ item.Id }} --operatingsystem 'Debian 9.3' - with_items: "{{ preseed_templates }}" - -- name: 'set default templates for Debian 9.3' - shell: > - {{ foreman_provisioning_hammer }} os set-default-template --id {{ foreman_provisioning_debian93.Id }} --provisioning-template-id {{ item.Id }} - with_items: "{{ preseed_templates }}" diff --git a/roles/foreman_provisioning/tasks/configure_fedora_27.yml b/roles/foreman_provisioning/tasks/configure_fedora_27.yml deleted file mode 100644 index 8895ab81a..000000000 --- a/roles/foreman_provisioning/tasks/configure_fedora_27.yml +++ /dev/null @@ -1,36 +0,0 @@ -- name: 'create Fedora 27' - shell: > - {{ foreman_provisioning_hammer }} os info --title "Fedora 27" || - {{ foreman_provisioning_hammer }} os create - --name Fedora --major 27 --architectures x86_64 --family 'Redhat' --media 'Fedora mirror' --partition-tables 'Kickstart default' - -- name: 'find Fedora 27' - shell: > - {{ foreman_provisioning_hammer }} --output json os info --name "Fedora 27" || - {{ foreman_provisioning_hammer }} --output json os info --title "Fedora 27" - register: foreman_provisioning_fedora27_json - ignore_errors: True - -- name: 'get Fedora 27 info' - set_fact: - foreman_provisioning_fedora27: "{{ foreman_provisioning_fedora27_json.stdout|from_json }}" - -- name: 'find kickstart templates' - shell: > - {{ foreman_provisioning_hammer }} --output=json template list - --search 'name ~ "Kickstart default"' - register: kickstart_templates_json - -- name: 'set kickstart templates' - set_fact: - kickstart_templates: "{{ kickstart_templates_json.stdout|from_json }}" - -- name: 'associate kickstart templates to Fedora 27' - shell: > - {{ foreman_provisioning_hammer }} template add-operatingsystem --id {{ item.Id }} --operatingsystem 'Fedora 27' - with_items: "{{ kickstart_templates }}" - -- name: 'set default templates for Fedora 27' - shell: > - {{ foreman_provisioning_hammer }} os set-default-template --id {{ foreman_provisioning_fedora27.Id }} --provisioning-template-id {{ item.Id }} - with_items: "{{ kickstart_templates }}" diff --git a/roles/foreman_provisioning/tasks/configure_fedora_40.yml b/roles/foreman_provisioning/tasks/configure_fedora_40.yml new file mode 100644 index 000000000..768b359d3 --- /dev/null +++ b/roles/foreman_provisioning/tasks/configure_fedora_40.yml @@ -0,0 +1,28 @@ +- name: "Find all relevant templates" # noqa: args[module] + theforeman.foreman.resource_info: + resource: provisioning_templates + search: name ~ "Kickstart default" or name = "Linux host_init_config default" + register: result + +- name: "Ensure Fedora 40" # noqa: args[module] + theforeman.foreman.operatingsystem: + name: Fedora + family: Redhat + major: 40 + architectures: + - x86_64 + media: + - Fedora mirror + provisioning_templates: "{{ result.resources | map(attribute='name') }}" + ptables: + - Kickstart default + state: present + password_hash: "SHA256" + +- name: "Set default template for Fedora 40" # noqa: args[module] + theforeman.foreman.os_default_template: + operatingsystem: "Fedora 40" + template_kind: "{{ item.template_kind_name }}" + provisioning_template: "{{ item.name }}" + state: present + loop: "{{ result.resources | sort(attribute='name') | unique(attribute='template_kind_name') }}" diff --git a/roles/foreman_provisioning/tasks/configure_ubuntu_17_10.yml b/roles/foreman_provisioning/tasks/configure_ubuntu_17_10.yml deleted file mode 100644 index 7e8caf7a8..000000000 --- a/roles/foreman_provisioning/tasks/configure_ubuntu_17_10.yml +++ /dev/null @@ -1,36 +0,0 @@ -- name: 'create Ubuntu 17.10' - shell: > - {{ foreman_provisioning_hammer }} os info --title "Ubuntu 17.10" || - {{ foreman_provisioning_hammer }} os create - --name Ubuntu --major 17 --minor 10 --release-name 'artful' --architectures x86_64 --family 'Debian' --media 'Ubuntu mirror' --partition-tables 'Preseed default' - -- name: 'find Ubuntu 17.10' - shell: > - {{ foreman_provisioning_hammer }} --output json os info --name "Ubuntu 17.10" || - {{ foreman_provisioning_hammer }} --output json os info --title "Ubuntu 17.10" - register: foreman_provisioning_ubuntu1710_json - ignore_errors: True - -- name: 'get Ubuntu 17.10 info' - set_fact: - foreman_provisioning_ubuntu1710: "{{ foreman_provisioning_ubuntu1710_json.stdout|from_json }}" - -- name: 'find preseed templates' - shell: > - {{ foreman_provisioning_hammer }} --output=json template list - --search 'name ~ "Preseed default"' - register: preseed_templates_json - -- name: 'set preseed templates' - set_fact: - preseed_templates: "{{ preseed_templates_json.stdout|from_json }}" - -- name: 'associate preseed templates to Ubuntu 17.10' - shell: > - {{ foreman_provisioning_hammer }} template add-operatingsystem --id {{ item.Id }} --operatingsystem 'Ubuntu 17.10' - with_items: "{{ preseed_templates }}" - -- name: 'set default templates for Ubuntu 17.10' - shell: > - {{ foreman_provisioning_hammer }} os set-default-template --id {{ foreman_provisioning_ubuntu1710.Id }} --provisioning-template-id {{ item.Id }} - with_items: "{{ preseed_templates }}" diff --git a/roles/foreman_provisioning/tasks/configure_ubuntu_24_04.yml b/roles/foreman_provisioning/tasks/configure_ubuntu_24_04.yml new file mode 100644 index 000000000..ba3e2b441 --- /dev/null +++ b/roles/foreman_provisioning/tasks/configure_ubuntu_24_04.yml @@ -0,0 +1,29 @@ +- name: "Find all relevant templates" # noqa: args[module] + theforeman.foreman.resource_info: + resource: provisioning_templates + search: name ~ "Preseed default" or name = "Linux host_init_config default" + register: result + +- name: "Ensure Ubuntu 24.04" # noqa: args[module] + theforeman.foreman.operatingsystem: + name: Ubuntu + family: Debian + major: "24.04" + release_name: artful + architectures: + - x86_64 + media: + - Ubuntu mirror + provisioning_templates: "{{ result.resources | map(attribute='name') }}" + ptables: + - Preseed default + state: present + password_hash: "SHA256" + +- name: "Set default template for Ubuntu 24.04" # noqa: args[module] + theforeman.foreman.os_default_template: + operatingsystem: "Ubuntu 24.04" + template_kind: "{{ item.template_kind_name }}" + provisioning_template: "{{ item.name }}" + state: present + loop: "{{ result.resources | sort(attribute='name', reverse=True) | unique(attribute='template_kind_name') }}" diff --git a/roles/foreman_provisioning/tasks/main.yml b/roles/foreman_provisioning/tasks/main.yml index c5b07ab0f..530ff3c1c 100644 --- a/roles/foreman_provisioning/tasks/main.yml +++ b/roles/foreman_provisioning/tasks/main.yml @@ -2,19 +2,20 @@ - name: 'Setup CentOS 9 provisioning' import_tasks: configure_centos_9.yml -- name: 'Setup Fedora 27 provisioning' - import_tasks: configure_fedora_27.yml +- name: 'Setup Fedora 40 provisioning' + import_tasks: configure_fedora_40.yml -- name: 'Setup Debian 9.3 provisioning' - import_tasks: configure_debian_9_3.yml +- name: 'Setup Debian 12.7 provisioning' + import_tasks: configure_debian_12_7.yml -- name: 'Setup Ubuntu 17.10 provisioning' - import_tasks: configure_ubuntu_17_10.yml +- name: 'Setup Ubuntu 24.04 provisioning' + import_tasks: configure_ubuntu_24_04.yml # TODO verify - should not be needed, DNS should work just fine - name: 'set unattended_url' - shell: > - {{ foreman_provisioning_hammer }} settings set --name unattended_url --value 'http://{{ foreman_provisioning_ip_address }}' + theforeman.foreman.setting: + name: unattended_url + value: "http://{{ foreman_provisioning_ip_address }}" - name: 'find hostgroup Base' shell: > @@ -37,30 +38,30 @@ --name 'Base' --architecture x86_64 --domain {{ foreman_provisioning_domain }} - --environment production + --puppet-environment production --puppet-ca-proxy-id {{ foreman_provisioning_smart_proxy.Id }} --puppet-proxy-id {{ foreman_provisioning_smart_proxy.Id }} --subnet '{{ foreman_provisioning_network }}/24' {{ foreman_provisioning_compute_profile_option }} {{ foreman_provisioning_compute_resource_option }} - --root-pass changeme + --root-password changeme --pxe-loader "PXELinux BIOS" --organization '{{ foreman_provisioning_organization }}' {{ foreman_provisioning_hammer_taxonomy_params }} when: foreman_provisioning_hostgroup_base.stderr.find('not found') != -1 -- name: 'find hostgroup CentOS 7' +- name: 'find hostgroup CentOS 9' shell: > - {{ foreman_provisioning_hammer }} hostgroup info --name 'CentOS 7 Mirror' + {{ foreman_provisioning_hammer }} hostgroup info --name 'CentOS 9 Mirror' register: foreman_provisioning_hostgroup_centos_mirror ignore_errors: True -- name: 'create hostgroup CentOS 7 Mirror' +- name: 'create hostgroup CentOS 9 Mirror' shell: > {{ foreman_provisioning_hammer }} hostgroup create - --name 'CentOS 7 Mirror' - --operatingsystem 'CentOS 7' - --medium '{{ centos_medium_name }}' + --name 'CentOS 9 Mirror' + --operatingsystem 'CentOS_Stream 9' + --medium '{{ foreman_provisioning_centos_medium_name }}' --partition-table 'Kickstart default' --parent 'Base' {{ foreman_provisioning_hammer_taxonomy_params }} diff --git a/roles/foreman_provisioning_infrastructure/tasks/main.yml b/roles/foreman_provisioning_infrastructure/tasks/main.yml index 5df78025b..be558ce1a 100644 --- a/roles/foreman_provisioning_infrastructure/tasks/main.yml +++ b/roles/foreman_provisioning_infrastructure/tasks/main.yml @@ -103,20 +103,20 @@ # Puppet - name: 'find environment' shell: > - {{ foreman_provisioning_hammer }} environment info --name "production" + {{ foreman_provisioning_hammer }} puppet-environment info --name "production" register: foreman_provisioning_environment ignore_errors: True - name: 'create environment' shell: > - {{ foreman_provisioning_hammer }} environment create + {{ foreman_provisioning_hammer }} puppet-environment create --name production {{ foreman_provisioning_hammer_taxonomy_params }} when: foreman_provisioning_environment.stderr.find('not found') != -1 - name: 'update environment' # it may have been automatically created by puppet if katello reports first shell: > - {{ foreman_provisioning_hammer }} environment update + {{ foreman_provisioning_hammer }} puppet-environment update --name production {{ foreman_provisioning_hammer_taxonomy_params }} diff --git a/roles/libvirt/tasks/tftp.yml b/roles/libvirt/tasks/tftp.yml index 0bc7f5e5c..11e9317fc 100644 --- a/roles/libvirt/tasks/tftp.yml +++ b/roles/libvirt/tasks/tftp.yml @@ -1,6 +1,6 @@ --- - name: 'create the provisioning libvirt network' - virt_net: + community.libvirt.virt_net: command: define name: provision xml: '{{ lookup("template", "../templates/network.xml.j2") }}' @@ -14,7 +14,7 @@ path: /etc/libvirt/qemu/networks/autostart/provision.xml - name: 'create the provisioning storage' - virt_pool: + community.libvirt.virt_pool: command: define name: provision xml: '{{ lookup("template", "../templates/storage.xml.j2") }}' @@ -58,13 +58,13 @@ shell: set -o pipefail && find /var/lib/tftpboot/ -type d | xargs chmod g+s - name: 'start the provision libvirt network' - virt_net: + community.libvirt.virt_net: state: active name: provision autostart: yes - name: 'start the provision libvirt storage pool' - virt_pool: + community.libvirt.virt_pool: state: active name: provision autostart: yes