-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rely on FAM for much of the foreman_provisioning setup #1888
Open
ekohl
wants to merge
1
commit into
theforeman:master
Choose a base branch
from
ekohl:use-more-fam
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+70
−141
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find this on https://theforeman.github.io/foreman-ansible-modules/develop/plugins/user_module.html#ansible-collections-theforeman-foreman-user-module and I'm wonder how this even works. |
||
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evgeni this is taken from the examples in https://theforeman.github.io/foreman-ansible-modules/develop/plugins/compute_profile_module.html#ansible-collections-theforeman-foreman-compute-profile-module but the description says it's a list, so should it be