Skip to content

Latest commit

 

History

History
268 lines (213 loc) · 11.9 KB

setup_fedora.md

File metadata and controls

268 lines (213 loc) · 11.9 KB

Steps to get a dev env for Staypuft development

Based on pchalupa's setup, if you find a bug/problem ping me irc #theforeman-dev channel.

Architecture

Bare-metal machine with: smart-proxy, puppet master, foreman, kvm, (virsh with dhcp and dns support on proxy). VMs provisioned in virtual network. Foreman web server process replaced, redirected in Apache to thin running form checkout with Staypuft.

Foreman

Installation

  • fresh Fedora 19 on bare-metal

  • yum -y install http://yum.theforeman.org/releases/1.5/f19/x86_64/foreman-release.rpm

  • yum -y install foreman-installer

  • yum -y install foreman-libvirt

  • disable selinux:

    • setenforce Permissive
    • edit /etc/sysconfig/selinux and set SELINUX=disabled
  • allow ports in firewall I've used F19 firewall config tool: firewall-config

    • enable in zone public
      • services: http, https, libvirt
      • ports: 8140 (puppetmaster), 8443 (proxy), 5900-5930 (vnc)
  • install yum install @virtualization

  • create/update subnet sudo virsh net-edit default

    <network>
      <name>default</name>
      <uuid>7c58ee26-2c78-4b4c-be8d-2d7f1ce9b4f8</uuid>
      <forward mode='nat'>
        <nat>
          <port start='1024' end='65535'/>
        </nat>
      </forward>
      <bridge name='virbr0' stp='on' delay='0' />
      <mac address='52:54:00:e4:89:49'/>
      <domain name='example.com'/>
      <ip address='192.168.100.1' netmask='255.255.255.0'>
        <tftp root='/var/lib/tftpboot/' />
        <dhcp>
          <range start='192.168.100.10' end='192.168.100.254' />
          <bootp file='pxelinux.0' />
        </dhcp>
      </ip>
    </network>
    
  • set fqdn of the bare-metal machine to foreman.example.com

    • hostname foreman.example.com
    • update /etc/hostname
    • add 192.168.100.1 foreman.example.com foreman line to /etc/hosts
  • fix non ASCI chars in /etc/fedora-release and if it exists /etc/fedoraversion replace ö with o and also remove the ' char.

  • run foreman-installer (to install foreman with default options)

    • use system ruby; rvm and rbenv can mess things up
    • If you get locale errors or related to operatingsystem version check: export LANG=en_GB.utf8
    • If you get the error: /Stage[main]/Foreman_proxy::Register/Foreman_smartproxy[martyn-work-laptop.example.com]: Could not evaluate: 404 Resource Not Found: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> try:

Configuration

Redirecting all traffic to other foreman web process running from git checkout

  • update httpd foreman config files both /etc/httpd/conf.d/05-foreman.conf and 05-foreman-ssl.conf

    # replace following line
    PassengerAppRoot /usr/share/foreman
    
    # with following:
    # PassengerAppRoot /usr/share/foreman
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
    LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
    
    <Proxy balancer://thinserversforeman>
      BalancerMember http://your.machine:3000/ # use fqdn not localhost
    </Proxy>
    
    RewriteEngine On
    # RewriteCond %{REQUEST_URI} !^/pulp.*$ # needed when installed with Katello
    RewriteRule ^/(.*)$ balancer://thinserversforeman%{REQUEST_URI} [P,QSA,L]
    ProxyPassReverse / http://your.machine:3000/
    ProxyPass / balancer://thinserversforeman
    ProxyPreserveHost on
    
  • Use same DB or copy to the other machine.

  • check the settings of your new foreman process: modulepath, foreman_url, ssl_ca_file, ssl_certificate, ssl_priv_key, unattended_url

Importing astapor puppet modules

Configure /etc/puppet/puppet.conf to point to openstack-puppet-modules and astapor modules.

  • Check out astapor and openstack-puppet-modules

    • from [email protected]:redhat-openstack/astapor.git and
    • from [email protected]:redhat-openstack/openstack-puppet-modules.git (use git clone --recursive ... to initialize the submodules).
  • Modify the [production] /modulepath section of /etc/puppet/puppet.conf:

    [production]
    modulepath     = /etc/puppet/environments/production/modules:/etc/puppet/environments/common:/usr/share/puppet/modules:/{git-root}/openstack-puppet-modules:{git-root}/astapor/puppet/modules
    
  • rake puppet:import:puppet_classes[batch]

    • If using the rpm version, then substitute foreman-rake for rake
  • If an error results stating that the sqlite3 gem is required, then: yum -y install ruby-devel gcc libsqlite3x-devel gem install sqlite3

Foreman Discovery setup

  • the plugin it is a dependency of Staypuft when #39 is merged

  • install the discovery plugin

    • Create /etc/yum.repos.d/foreman_plugins.repo containing the following: [foreman-plugins] name=Foreman plugins baseurl=http://yum.theforeman.org/plugins/1.6/el6/x86_64/ enabled=1 gpgcheck=0
    • yum -y install rubygem-foreman_discovery.noarch
    • reboot the system (systemctl restart foreman is not sufficient by itself)
  • install tftp images, on the machine with proxy execute:

    • cd /var/lib/tftpboot/boot
    • wget http://downloads.theforeman.org/discovery/nightly/foreman-discovery-image-latest.el6.iso-img
    • wget http://downloads.theforeman.org/discovery/nightly/foreman-discovery-image-latest.el6.iso-vmlinuz
  • in the foreman GUI, navigate to Administer->Settings->Provisioning. Set safemode_render to false and click Save. This is required for <%= Setting['foreman_url'] %> to work in the PXELinux global default template below.

  • navigate to Hosts->Provisioning templates. Edit the PXELinux global default template. Change the template code to the following and click Submit:

    <%#
      kind: PXELinux
      name: Community PXE Default
    %>
    
    <%# This template has special name (do not change it) and it is used for booting unknown hosts. %>
    
    DEFAULT menu
    PROMPT 0
    MENU TITLE PXE Menu
    TIMEOUT 200
    TOTALTIMEOUT 6000
    ONTIMEOUT discovery
    
    LABEL discovery
    MENU LABEL Foreman Discovery
    KERNEL boot/foreman-discovery-image-latest.el6.iso-vmlinuz
    APPEND rootflags=loop initrd=boot/foreman-discovery-image-latest.el6.iso-img root=live:/foreman.iso rootfstype=auto ro rd.live.image rd.live.check rd.lvm=0 rootflags=ro crashkernel=128M elevator=deadline max_loop=256 rd.luks=0 rd.md=0 rd.dm=0 foreman.url=<%= Setting['foreman_url'] %> nomodeset selinux=0 stateless
    IPAPPEND 2
    
  • click the Build PXE Default button in the upper right corner

  • foreman web process has to have access to discovered hosts by IP adresses, if the foreman web process is running on the same machine as the virtual network then all is good, otherwise:

    • set static routes from machine with foreman web process to the virtual network sudo route -n add 192.168.100.0/24 foreman.example.com
    • update iptables on machine hosting the virtual network
      • enable logging of TRACE target modprobe ipt_LOG
      • add kern.debug /var/log/iptables to /etc/rsyslog.conf
      • restart systemctl restart rsyslog.service
      • add rule to trace the incoming packet iptables -A PREROUTING -t raw --source 10.34.131.187 --destination 192.168.100.53 -j TRACE
      • try to access a machine on private network
      • look into /var/log/iptables which rule REJECTed the packet
      • add rule ACCEPTing the packets above the rejecting rule in my case iptables -t filter -I FORWARD 15 -o virbr0 -s 10.34.131.187 -j ACCEPT before the rejecting one in FORWARD chain REJECT all -- * virbr0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
      • TODO make static routes and iptable changes permanent
  • create a machine in libvirt and let it be discovered

Create a provision kick start template for open stack:

Enabling Puppet SSH

This is required for invoking puppet runs on remote machines. This will be needed in future versions of Staypuft for orchestration tasks.

  • Enable Puppet Run

    • Go to the foreman web UI. Administer -> Settings -> Puppet
    • Set Puppet Run to 'true'
  • Configure Foreman Proxy

  • Create SSH Key for foreman-proxy

    # Create SSH Key using ssh-keygen
    # cp private key to /etc/foreman-proxy/
    chown foreman-proxy /etc/foreman-proxy/id_rsa
    chmod 600 /etc/foreman-proxy/id_rsa
    
  • Turn off StrictHostChecking for the foreman-proxy user

  • Distribute Foreman Public Key to Hosts

  • Restart foreman-proxy, sudo service foreman-proxy restart