forked from theforeman/forklift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rely on FAM for much of the foreman_provisioning setup
- Loading branch information
Showing
4 changed files
with
70 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 19 additions & 20 deletions
39
roles/foreman_provisioning_infrastructure/tasks/compute_profiles.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
--- | ||
- name: 'find compute profile' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} compute-profile info --name "libvirt-profile" | ||
register: foreman_provisioning_compute_profile | ||
ignore_errors: True | ||
|
||
- name: 'create compute profile' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} compute-profile create | ||
--name "libvirt-profile" | ||
when: "'Error' in foreman_provisioning_compute_profile.stderr" | ||
|
||
- name: 'create compute attributes' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} compute-profile values create | ||
--compute-profile libvirt-profile | ||
--compute-resource libvirt | ||
--volume pool_name=provision,capacity=15G,format_type=qcow2 | ||
--interface type=network,network=provision,model=virtio | ||
--compute-attributes cpus=1,memory=2400000000,start=1 | ||
when: "'Error' in foreman_provisioning_compute_profile.stderr" | ||
theforeman.foreman.compute_profile: | ||
name: libvirt-profile | ||
compute_resource: libvirt | ||
compute_attributes: | ||
- compute_resource: libvirt | ||
vm_attrs: | ||
cpus: 1 | ||
memory: 2400000000 | ||
start: 1 | ||
nics_attributes: | ||
0: | ||
type: network | ||
network: provision | ||
model: virtio | ||
volume_attributes: | ||
0: | ||
pool_name: provision | ||
capacity: 15G | ||
format_type: qcow2 |
158 changes: 48 additions & 110 deletions
158
roles/foreman_provisioning_infrastructure/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,64 @@ | ||
--- | ||
# Make sure admin does not default to any taxonomy | ||
- name: 'disable default context for admin' | ||
# TODO: how to pass org and location IDs 0 to FAM? | ||
shell: > | ||
{{ foreman_provisioning_hammer }} user update --login admin --default-organization-id 0 --default-location-id 0 | ||
# Get the smart proxy ID of the local katello: | ||
- name: 'get smart proxy id' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} --output json proxy info --name {{ foreman_provisioning_proxy_name }} | ||
register: foreman_provisioning_smart_proxy_json | ||
|
||
- name: 'set smart proxy id' | ||
set_fact: | ||
foreman_provisioning_smart_proxy: "{{ foreman_provisioning_smart_proxy_json.stdout|from_json }}" | ||
|
||
- name: 'refresh features' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} proxy refresh-features --id {{ foreman_provisioning_smart_proxy.Id }} | ||
- name: 'prepare hammer taxonomy options' | ||
set_fact: | ||
foreman_provisioning_hammer_taxonomy_params: "--organizations '{{ foreman_provisioning_organization }}' --locations '{{ foreman_provisioning_location }}'" | ||
|
||
- name: 'Set taxonomies for proxy' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} proxy update --id {{ foreman_provisioning_smart_proxy.Id }} {{ foreman_provisioning_hammer_taxonomy_params }} | ||
# Compute Resource | ||
- name: 'find compute resource' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} compute-resource info --name "libvirt" | ||
register: foreman_provisioning_compute_resource | ||
ignore_errors: True | ||
theforeman.foreman.smart_proxy: | ||
name: "{{ foreman_provisioning_proxy_name }}" | ||
organizations: | ||
- "{{ foreman_provisioning_organization }}" | ||
locations: | ||
- "{{ foreman_provisioning_location }}" | ||
|
||
- name: 'create compute resource' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} compute-resource create | ||
--name "libvirt" | ||
--url "qemu:///system" | ||
--provider libvirt | ||
--set-console-password false | ||
{{ foreman_provisioning_hammer_taxonomy_params }} | ||
when: foreman_provisioning_compute_resource.stderr.find('not found') != -1 | ||
|
||
- name: 'Find out if compute profile command is available' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} compute-profile | ||
register: foreman_provisioning_compute_profile_cmd | ||
ignore_errors: True | ||
|
||
- include_tasks: compute_profiles.yml | ||
when: "'Error' not in foreman_provisioning_compute_profile_cmd.stderr" | ||
|
||
# Domain | ||
- name: 'find domain' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} domain info --name "{{ foreman_provisioning_domain }}" | ||
register: foreman_provisioning_domain_task | ||
ignore_errors: True | ||
theforeman.foreman.compute_resource: | ||
name: "libvirt" | ||
url: "qemu:///system" | ||
provider: libvirt | ||
set_console_password: false | ||
|
||
- name: 'create domain' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} domain create | ||
--name {{ foreman_provisioning_domain }} | ||
--dns-id {{ foreman_provisioning_smart_proxy.Id }} | ||
{{ foreman_provisioning_hammer_taxonomy_params }} | ||
when: foreman_provisioning_domain_task.stderr.find('not found') != -1 | ||
|
||
- name: 'update domain' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} domain update | ||
--name {{ foreman_provisioning_domain }} | ||
--dns-id {{ foreman_provisioning_smart_proxy.Id }} | ||
{{ foreman_provisioning_hammer_taxonomy_params }} | ||
when: "'Error' not in foreman_provisioning_domain_task.stderr" | ||
|
||
# Subnet | ||
- name: 'find subnet' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} subnet info --name "{{ foreman_provisioning_network }}/24" | ||
register: foreman_provisioning_subnet | ||
ignore_errors: True | ||
theforeman.foreman.domain: | ||
name: "{{ foreman_provisioning_domain }}" | ||
dns_proxy: "{{ foreman_provisioning_proxy_name }}" | ||
organizations: | ||
- "{{ foreman_provisioning_organization }}" | ||
locations: | ||
- "{{ foreman_provisioning_location }}" | ||
|
||
- name: 'create subnet' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} subnet create | ||
--name "{{ foreman_provisioning_network }}/24" | ||
--dhcp-id {{ foreman_provisioning_smart_proxy.Id }} | ||
--dns-id {{ foreman_provisioning_smart_proxy.Id }} | ||
--tftp-id {{ foreman_provisioning_smart_proxy.Id }} | ||
--domains {{ foreman_provisioning_domain }} | ||
--from {{ foreman_provisioning_dhcp_start }} | ||
--to {{ foreman_provisioning_dhcp_end }} | ||
--network {{ foreman_provisioning_network }} | ||
--mask 255.255.255.0 | ||
--ipam DHCP | ||
--gateway {{ foreman_provisioning_ip_address }} | ||
--dns-primary {{ foreman_provisioning_ip_address }} | ||
{{ foreman_provisioning_hammer_taxonomy_params }} | ||
when: foreman_provisioning_subnet.stderr.find('not found') != -1 | ||
|
||
# Puppet | ||
- name: 'find environment' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} environment info --name "production" | ||
register: foreman_provisioning_environment | ||
ignore_errors: True | ||
|
||
- name: 'create environment' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} 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 | ||
--name production | ||
{{ foreman_provisioning_hammer_taxonomy_params }} | ||
theforeman.foreman.subnet: | ||
name: "{{ foreman_provisioning_network }}/{{ foreman_provisioning_network_cidr }}" | ||
dhcp_proxy: "{{ foreman_provisioning_smart_proxy }}" | ||
dns_proxy: "{{ foreman_provisioning_smart_proxy }}" | ||
tftp_proxy: "{{ foreman_provisioning_smart_proxy }}" | ||
domains: | ||
- "{{ foreman_provisioning_domain }}" | ||
from_ip: "{{ foreman_provisioning_dhcp_start }}" | ||
to_ip: "{{ foreman_provisioning_dhcp_end }}" | ||
network: "{{ foreman_provisioning_network }}" | ||
cidr: "{{ foreman_provisioning_network_cidr }} " | ||
ipam: DHCP | ||
gateway: "{{ foreman_provisioning_ip_address }}" | ||
dns_primary: "{{ foreman_provisioning_ip_address }}" | ||
organizations: | ||
- "{{ foreman_provisioning_organization }}" | ||
locations: | ||
- "{{ foreman_provisioning_location }}" | ||
|
||
- name: 'create Puppet environment' | ||
theforeman.foreman.puppet_environment: | ||
name: production | ||
organizations: | ||
- "{{ foreman_provisioning_organization }}" | ||
locations: | ||
- "{{ foreman_provisioning_location }}" | ||
|
||
# query local nameservers http://projects.theforeman.org/issues/13419 | ||
- name: 'query local nameservers' | ||
shell: > | ||
{{ foreman_provisioning_hammer }} settings set --name query_local_nameservers --value true | ||
theforeman.foreman.setting: | ||
name: query_local_nameservers | ||
value: true |