--- - hosts: foreman become: true tasks: - name: install puppet-prometheus command: /opt/puppetlabs/bin/puppet module install puppet-prometheus args: creates: /etc/puppetlabs/code/environments/production/modules/prometheus/ - name: import puppet modules into Foreman command: hammer proxy import-classes --puppet-environment production --name {{ ansible_fqdn }} - hosts: localhost collections: - theforeman.foreman gather_facts: false vars_files: - vars/server.yml - vars/host.yml tasks: - include_tasks: tasks/organization.yml vars: organization_name: "{{ host.organization }}" organization_state: present - include_tasks: tasks/location.yml vars: location_name: "{{ host.location }}" location_organizations: - "{{ host.organization }}" location_state: present - include_tasks: tasks/organization.yml vars: organization_name: "{{ host.organization }} Secondary" organization_state: present - include_tasks: tasks/location.yml vars: location_name: "{{ host.location }} Secondary" location_organizations: - "{{ host.organization }} Secondary" location_state: present - include_tasks: tasks/domain.yml vars: domain_name: "{{ host.domain }}" domain_locations: - "{{ host.location }}" domain_organizations: - "{{ host.organization }}" domain_state: present - include_tasks: tasks/subnet.yml vars: subnet_name: "{{ host.subnet }}" subnet_mask: '255.255.255.224' subnet_domains: - "{{ host.domain }}" subnet_locations: - "{{ host.location }}" subnet_organizations: - "{{ host.organization }}" subnet_state: present - include_tasks: tasks/hostgroup.yml vars: hostgroup_name: "{{ host.hostgroup }}" hostgroup_domain: "{{ host.domain }}" hostgroup_locations: - "{{ host.location }}" hostgroup_organizations: - "{{ host.organization }}" hostgroup_state: present - include_tasks: tasks/hostgroup.yml vars: hostgroup_name: "{{ host.hostgroup }}/child_group" hostgroup_domain: "{{ host.domain }}" hostgroup_locations: - "{{ host.location }}" hostgroup_organizations: - "{{ host.organization }}" hostgroup_state: present - include_tasks: tasks/user.yml vars: user_state: present user_password: password - include_tasks: tasks/usergroup.yml vars: usergroup_state: present - include_tasks: tasks/architecture.yml vars: architecture_name: "{{ host.arch }}" architecture_state: present - include_tasks: tasks/operatingsystem.yml vars: operatingsystem_name: "{{ host.os.name }}" operatingsystem_major: "{{ host.os.major }}" operatingsystem_minor: "{{ host.os.minor }}" operatingsystem_family: "{{ host.os.family }}" operatingsystem_architectures: - "{{ host.arch }}" operatingsystem_state: present - include_tasks: tasks/environment.yml vars: environment_state: present environment_name: "production" environment_locations: - "{{ host.location }}" environment_organizations: - "{{ host.organization }}" - include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent - hosts: tests collections: - theforeman.foreman gather_facts: false vars_files: - vars/server.yml - vars/host.yml tasks: - name: create host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false expected_change: true - name: create host again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false expected_change: false - name: update host, set owner to a user include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_owner: test expected_change: true - name: update host, set owner to a user again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_owner: test expected_change: false - name: update host, set owner to a usergroup include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_owner_group: testgroup expected_change: true - name: update host, set owner to a usergroup again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_owner_group: testgroup expected_change: false - name: Add subnet to host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_subnet: "{{ host.subnet }}" host_managed: false expected_change: true - name: Add subnet to host again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_subnet: "{{ host.subnet }}" host_managed: false expected_change: false - name: delete host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: true - name: delete host again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: false - name: create host with hostgroup include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_hostgroup: "{{ host.hostgroup }}" host_managed: false host_build: false expected_change: true - name: create host again with hostgroup, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_hostgroup: "{{ host.hostgroup }}" host_managed: false host_build: false expected_change: false - name: move host to child hostgroup include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_hostgroup: "{{ host.hostgroup }}/child_group" host_managed: false host_build: false expected_change: true - name: move host again to child hostgroup, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_hostgroup: "{{ host.hostgroup }}/child_group" host_managed: false host_build: false expected_change: false - name: delete host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: true - name: delete host again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: false - name: create host with nested hostgroup include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_hostgroup: "{{ host.hostgroup }}/child_group" host_managed: false host_build: false expected_change: true - name: create host again with nested hostgroup, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_hostgroup: "{{ host.hostgroup }}/child_group" host_managed: false host_build: false expected_change: false - name: delete host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: true - name: delete host again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: false - name: create host with ip and mac include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_ip: "192.0.2.23" host_mac: "EE:FF:00:00:00:01" host_managed: false host_build: false expected_change: true - name: create host again with ip and mac include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_ip: "192.0.2.23" host_mac: "EE:FF:00:00:00:01" host_managed: false host_build: false expected_change: false - name: delete host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: true - name: create host with os and arch include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_operatingsystem: "{{ host.os.name }}" host_architecture: "{{ host.arch }}" expected_change: true - name: create host with os and arch again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_operatingsystem: "{{ host.os.name }}" host_architecture: "{{ host.arch }}" expected_change: false - name: delete host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: true - name: create host with puppetclasses include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_environment: production host_puppetclasses: - "prometheus::redis_exporter" expected_change: true - name: create host with puppetclasses again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_environment: production host_puppetclasses: - "prometheus::redis_exporter" expected_change: false - name: update host with puppetclasses include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_environment: production host_puppetclasses: - "prometheus::haproxy_exporter" expected_change: true - name: update host with puppetclasses again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_environment: production host_puppetclasses: - "prometheus::haproxy_exporter" expected_change: false - name: update host with puppetclasses and description include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_description: nice host host_environment: production host_puppetclasses: - "prometheus::redis_exporter" expected_change: true - name: update host with puppetclasses and description again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_description: nice host host_environment: production host_puppetclasses: - "prometheus::redis_exporter" expected_change: false - name: remove puppetclasses from host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_puppetclasses: [] expected_change: true - name: remove puppetclasses from host again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false host_puppetclasses: [] expected_change: false - name: delete host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: true - name: create host in first org/loc include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }}" host_location: "{{ host.location }}" host_managed: false host_build: false expected_change: true - name: move host to second org/loc include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }} Secondary" host_location: "{{ host.location }} Secondary" host_managed: false host_build: false expected_change: true - name: move host to second org/loc again, no change include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_organization: "{{ host.organization }} Secondary" host_location: "{{ host.location }} Secondary" host_managed: false host_build: false expected_change: false - name: delete host include_tasks: tasks/host.yml vars: host_name: "test-host.{{ host.domain }}" host_state: absent expected_change: true - hosts: localhost collections: - theforeman.foreman gather_facts: false vars_files: - vars/server.yml - vars/host.yml tasks: - include_tasks: tasks/user.yml vars: user_state: absent - include_tasks: tasks/usergroup.yml vars: usergroup_state: absent - include_tasks: tasks/hostgroup.yml vars: hostgroup_name: "{{ host.hostgroup }}/child_group" hostgroup_state: absent - include_tasks: tasks/hostgroup.yml vars: hostgroup_name: "{{ host.hostgroup }}" hostgroup_state: absent - include_tasks: tasks/subnet.yml vars: subnet_name: "{{ host.subnet }}" subnet_mask: '255.255.255.224' subnet_domains: [] subnet_state: present - include_tasks: tasks/subnet.yml vars: subnet_name: "{{ host.subnet }}" subnet_mask: '255.255.255.224' subnet_state: absent - include_tasks: tasks/domain.yml vars: domain_name: "{{ host.domain }}" domain_state: absent - include_tasks: tasks/operatingsystem.yml vars: operatingsystem_name: "{{ host.os.name }}" operatingsystem_state: absent - include_tasks: tasks/architecture.yml vars: architecture_name: "{{ host.arch }}" architecture_state: absent - include_tasks: tasks/location.yml vars: location_name: "{{ host.location }} Secondary" location_state: absent - include_tasks: tasks/organization.yml vars: organization_name: "{{ host.organization }} Secondary" organization_state: absent - include_tasks: tasks/location.yml vars: location_name: "{{ host.location }}" location_state: absent - include_tasks: tasks/organization.yml vars: organization_name: "{{ host.organization }}" organization_state: absent ...