Skip to content
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

Provisioning support #295

Merged
merged 11 commits into from
Sep 30, 2016
Merged

Provisioning support #295

merged 11 commits into from
Sep 30, 2016

Conversation

stbenjam
Copy link
Member

@stbenjam stbenjam commented Sep 13, 2016

How to use this:

  1. Enable nested virt on your phyiscal box: http://www.rdoxenham.com/?p=275. See Dominic's comment on the post, basically this and reboot (or rmmod kvm-intel; modprobe kvm-intel):

    echo "options kvm-intel nested=1" | sudo tee /etc/modprobe.d/kvm-intel.conf
    
  2. Option 1: Use the centos7-provisioning-nightly box.

    Option 2: Use an existing katello box (e.g. centos7-katello-p4-nightly) and run the provisioning playbook (it takes a while, as it syncs (on-demand) centos7, puppet 4). Note: If you are using puppet 4, you need to increase the ram on the box, to something like 8096 otherwise candlepin crashes with OOM.

    ansible-playbook -l centos7-katello-p4-nightly playbooks/katello_provisioning.yml 
    
  3. Login and create a compute profile, because this isn't possible with hammer or the API.

    • Click Infrastructure / Compute Resources
    • Click "libvirt"
    • Click Compute profiles
    • Click 2-Medium
      • increse ram to 1024MB (required for centos 7)
      • change network type to NAT, network name = provision
    • Click Submit
  4. Configure Activation Key

  • Content/ Activation Keys
  • Assign all available subscriptions to the activation key
  1. Configure / Host groups
    • Edit Forklift CentOS 7
    • Set Compute profile to be "2-Medium"
    • Assign the CentOS 7 activation key to the host group
  2. You're good to go! Let's provision a box!
    • Click Hosts/ New Host

    • Fill in:
      - org, location, host group
      - deploy on = libvirt

      DONE! Click submit 🎉

  3. If you want to view the console while it boots, make sure to trust the CA certificate in your browser, it's hosted at https://centos7-katello-nightly.example.com/pub/katello-server-ca.crt, and you'll need to make sure you're accessing the katello via it's proper hostname (add an entry to /etc/hosts)

name: provision

- name: 'install libvirt gem'
yum: name=rubygem-ruby-libvirt state=present
Copy link
Member Author

@stbenjam stbenjam Sep 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DHCP not working: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-65343dc650

The update needs another karma to get pushed to EPEL stable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the interim, before running the playbook, run this on the Katello

 yum localinstall https://kojipkgs.fedoraproject.org//packages/rubygem-ruby-libvirt/0.6.0/1.el7/x86_64/rubygem-ruby-libvirt-0.6.0-1.el7.x86_64.rpm

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can throw this into the playbook for now if you want, I added karma to try to help the package along.

@ehelms
Copy link
Member

ehelms commented Sep 14, 2016

Awesome idea! What do you think about stacking the shell commands like https://github.com/Katello/forklift/pull/295/files#diff-4fc9c0aa4c54f421837dada92f7c1c01R4 ? I find that to be much more readable (and editable) than a single long line.

@ehelms
Copy link
Member

ehelms commented Sep 14, 2016

We could also (as a future enhancement) consider adding this as we need them to (https://github.com/ansible/ansible-modules-extras/pull/2450/files) or looking into a similar one based on a prototype I did to allow passing "generic" hammer commands. One thing the shell command way lacks is that if you do a create it doesn't check whether the object exists already or not to do an update can error out.

name: provision
xml: '{{ lookup("template", "../templates/provision.xml.j2") }}'

# Setup TFTP for libvirt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a duplication of the tftp setup that the installer does. Why can't that be used instead?

Copy link
Member Author

@stbenjam stbenjam Sep 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it do it? I'll have a look. I'm basing it off the blog post for libvirt foreman environments, maybe it's outdated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the setuid I think it should do the steps you mention here. I'd be interested if we need to do more to support this properly.

Copy link
Member Author

@stbenjam stbenjam Sep 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be done, at least creating the dierctory, because of a bit of a chicken and egg problem. You can't bring the libvirt network up if /var/lib/tftpboot doesn't exist, but you can't run the installer unless the virbr1 exists.

 Evaluation Error: Error while evaluating a Function Call, Could not get the ip address from fact ipaddress_virbr1 at /usr/share/foreman-installer/modules/foreman_proxy/manifests/proxydhcp.pp:8:5 on node centos7-katello-p4-nightly.example.com

I could run the installer twice, once with tftp enable, and then again later with DHCP, but I'd rather not, it's too time consuming especially with Katello.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it just requires tftpboot to exist then maybe just leave that in? The installer can then ensure it contains the right data.

@stbenjam
Copy link
Member Author

It should work now, and it's somewhat idempotent. I updated the description of the PR with instructions.

@ekohl
Copy link
Member

ekohl commented Sep 15, 2016

Since theforeman/puppet-foreman_proxy#267 was merged you need to duplicate the tftp stuff again.

@@ -0,0 +1 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional file?

# https://github.com/Katello/hammer-cli-import/pull/31
- shell: >
sudo rm /etc/hammer/cli.modules.d/import.yml
ignore_errors: True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

---
# https://github.com/Katello/katello/pull/6311
- shell: >
wget https://raw.githubusercontent.com/bbuckingham/katello/5608b835b01dbe39cbea48ffad11396c83fd684d/app/controllers/katello/concerns/api/v2/hostgroups_controller_extensions.rb -O /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.2.0/app/controllers/katello/concerns/api/v2/hostgroups_controller_extensions.rb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed for non-master Katello boxes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a non-master Katello box?

@@ -0,0 +1 @@
/home/stbenjam/git/ansible-modules-extras
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental?

# Product
- name: 'find product'
shell: >
{{ katello_provisioning_hammer }} product info --name "CentOS" --organization "{{ katello_provisioning_organization }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Repo
- name: 'find repo'
shell: >
{{ katello_provisioning_hammer }} repository info --name "CentOS 7" --product "CentOS" --organization "{{ katello_provisioning_organization }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Activation key
- name: 'find activation key'
shell: >
{{ katello_provisioning_hammer }} activation-key info --name "CentOS 7" --organization "{{ katello_provisioning_organization }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--environment production
--puppet-ca-proxy-id {{ katello_provisioning_smart_proxy.Id }}
--puppet-proxy-id {{ katello_provisioning_smart_proxy.Id }}
--subnet "192.168.73.0/24"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used in two locations might be worth variablizing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd make users think it's changeable, but they're not. The subnet config is more than just this name.

There's a bunch that could be variablized but I want to get a first iteration in before customizing everything.

--organizations "{{ katello_provisioning_organization }}"
--query-organization "{{ katello_provisioning_organization }}"
--partition-table "Kickstart default"
--medium "{{ katello_provisioning_organization|regex_replace('\s', '_') }}/Library/CentOS/CentOS_7"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make this into a variable so you are performing this operation on the data in only one spot

- hosts: all
become: true
roles:
- test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intended to be here still?

The idea here is that you can run the playbook on any old box:

  ansible-playbook -l centos7-katello-p4-nightly playbooks/katello_provisioning.yml

Needs a bunch of work to not assume the proxy id being 1 (e.g. you've
had the katello for a while).
@stbenjam
Copy link
Member Author

@beav This should be testable, I'd reccomend using the centos7-provisioning-nightly box included here. See description for full steps.

In addition to Katello/katello#6317, you will need to add this to the puppet_setup theforeman/community-templates#299 snippet. It's not in Foreman nightly yet.

@beav
Copy link
Contributor

beav commented Sep 20, 2016

@stbenjam the setup steps worked for me, except the nested VM came up in 'paused' state. I am not sure if that is expected or not

@stbenjam
Copy link
Member Author

stbenjam commented Sep 20, 2016

@beav Is nested virt working? vmx shows up in cat /proc/cpuinfo on the katello?

@beav
Copy link
Contributor

beav commented Sep 20, 2016

oh i had to do a virsh reset on it, not sure what the deal was but it's good now. I assume it was related to me reloading the kernel module but not bouncing libvirtd or something.

This PR works as advertised for me 🎆

@beav
Copy link
Contributor

beav commented Sep 20, 2016

@stbenjam what is the best way to get ssh access to the nested guest? I am having some trouble with ping or ssh, but I did see the centos install happen and complete (qemu process used a lot of cpu, then died down and "build" went to "installed" state)

@stbenjam
Copy link
Member Author

It's a NAT network that only exists on the katello, so you should be able to ssh to the katello, and then ssh to the guest. Password is changeme (set by the host group).

Or on the console in the Foreman UI.

@beav
Copy link
Contributor

beav commented Sep 21, 2016

My browser didn't have a way to access port 5900 on the provisioning server, but I was able to use vncviewer with an ssh tunnel.

@ehelms
Copy link
Member

ehelms commented Sep 21, 2016

Testing this myself, after clicking submit on the host I hit:

Error connecting to 'example.com' domain DNS servers: sns.dns.icann.org - check query_local_nameservers and dns_conflict_timeout settings

@stbenjam
Copy link
Member Author

Can you share the foreman production log? Were there any unignored errors in the playbook? You shouldn't hit that, the katello is authoritative for example.com.

@stbenjam
Copy link
Member Author

stbenjam commented Sep 21, 2016

Also, did you follow all the manual steps? Including setting the network type to NAT and the name 'provision' for the compute profile?

@beav
Copy link
Contributor

beav commented Sep 21, 2016

the provision network likely needs to be added to libvirtd autostart, otherwise provisioning doesn't work after a reboot

@ehelms
Copy link
Member

ehelms commented Sep 21, 2016

All manual steps as far as I can tell, I am seeing this in the production.log:

2016-09-21 13:25:16 30c071df [app] [W] Error connecting to 'example.com' domain DNS servers: sns.dns.icann.org - check query_local_nameservers and dns_conflict_timeout settings
 | Net::Error: execution expired
 | /usr/share/foreman/lib/net/dns.rb:62:in `rescue in lookup'
 | /usr/share/foreman/lib/net/dns.rb:20:in `lookup'
 | /usr/share/foreman/lib/net/dns.rb:87:in `dns_lookup'
 | /usr/share/foreman/lib/net/dns/forward_record.rb:22:in `conflicts'
 | /usr/share/foreman/lib/net.rb:23:in `conflicting?'
 | /usr/share/foreman/app/models/concerns/orchestration/dns.rb:111:in `block in dns_conflict_detected?'
 | /usr/share/foreman/app/models/concerns/orchestration/dns.rb:110:in `each'
 | /usr/share/foreman/app/models/concerns/orchestration/dns.rb:110:in `dns_conflict_detected?'
2016-09-21 13:25:16 30c071df [app] [I] Failed to save: Error connecting to 'example.com' domain DNS servers: sns.dns.icann.org - check query_local_nameservers and dns_conflict_timeout settings, Mac can't be blank, Base Error connecting to 'example.com' domain DNS servers: sns.dns.icann.org - check query_local_nameservers and dns_conflict_timeout settings

@ehelms
Copy link
Member

ehelms commented Sep 21, 2016

@stbenjam the manual steps might be good to have in a docs section to easily reference them. For those manual steps, are there open Redmine issues to alleviate the need for them?

@stbenjam
Copy link
Member Author

stbenjam commented Sep 26, 2016

@ehelms That error makes me think something is misconfigured in your VM. What is the resolv.conf set to use on that box?

@ehelms
Copy link
Member

ehelms commented Sep 27, 2016

[root@centos7-provision-nightly vagrant]# cat /etc/resolv.conf 
# Generated by NetworkManager
search example.com
nameserver 192.168.121.1

@stbenjam
Copy link
Member Author

stbenjam commented Sep 27, 2016

Foreman's trying to lookup the host record XXXX.example.com when creating a host, and that lookup for some reason is going out to the internet instead of using the local resolvers. No idea why Foreman prefers that.

But, it won't work in a Red Hat office, as we use a DNS sinkhole. You can't connect to anything on port 53 on the internet.

@stbenjam
Copy link
Member Author

@ehelms Change query_local_nameservers setting to true, I think that should fix it.

http://projects.theforeman.org/issues/13419

@stbenjam stbenjam changed the title [WIP] Provisioning support Provisioning support Sep 27, 2016
@stbenjam
Copy link
Member Author

Ready for another look. I set query_local_nameservers to true automatically, and broke out libvirt_setup so it could be used standalone.

@stbenjam
Copy link
Member Author

And added docs.


## How to configure

1. Enable nested virt on your phyiscal box. See http://www.rdoxenham.com/?p=275
Copy link
Member

@ehelms ehelms Sep 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could turn the link into something clickable with markdown using []() syntax

EDIT: Ignore me, it does that already if the link is used.

5. Configure Activation Key

- Content/ Activation Keys
- Assign all available subscriptions to the activation key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We in theory should be able to do this with the API or hammer (not requiring it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible, but it's a mess of grepping and fact registration, since you need the UUID. I can save it for a future enhancement...

@ehelms
Copy link
Member

ehelms commented Sep 27, 2016

Looking good, got a host up except that its been in 'Pending Installation' state for a bit now.

One general comment: I assume you are putting the Katello client repo and the puppet repos in the CentOS product for simplification? The downside I see there is it doesn't promote how we generally tell users to layout their products and repositories. I'm OK leaving it as is to get this available to people, just thought it worth commenting on.

@stbenjam
Copy link
Member Author

Looking good, got a host up except that its been in 'Pending Installation' state for a bit now.

Can you look at the console of the VM and see what it's doing?

One general comment: I assume you are putting the Katello client repo and the puppet repos in the CentOS product for simplification? The downside I see there is it doesn't promote how we generally tell users to layout their products and repositories. I'm OK leaving it as is to get this available to people, just thought it worth commenting on.

I could reorganize it, but was just trying to keep it simple. How would you prefer it to be laid out?

@ehelms
Copy link
Member

ehelms commented Sep 29, 2016

Meh -- that can always be done later if we want. ACK

@stbenjam stbenjam merged commit 9bbddf4 into theforeman:master Sep 30, 2016
@stbenjam stbenjam deleted the provisioning branch September 30, 2016 13:51
@beav
Copy link
Contributor

beav commented Sep 30, 2016

🎊

daviddavis pushed a commit to daviddavis/forklift that referenced this pull request Feb 21, 2017
* [WIP] Provisioning support

The idea here is that you can run the playbook on any old box:

  ansible-playbook -l centos7-katello-p4-nightly playbooks/katello_provisioning.yml
johnpmitsch pushed a commit to johnpmitsch/forklift that referenced this pull request Jun 27, 2019
* [WIP] Provisioning support

The idea here is that you can run the playbook on any old box:

  ansible-playbook -l centos7-katello-p4-nightly playbooks/katello_provisioning.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants