3 #bootstrap script for VM OPNFV nodes
4 #author: Tim Rozet (trozet@redhat.com)
6 #Uses Vagrant and VirtualBox
7 #VagrantFile uses vm_nodes_provision.sh which configures linux on nodes
8 #Depends on Foreman being up to be able to register and apply puppet
11 #Target system should be Centos7 Vagrant VM
26 echo "${blue} Setting Hostname ${reset}"
27 hostnamectl set-hostname $host_name
30 echo "${blue} Removing DNS server on first interface ${reset}"
31 if ! grep 'PEERDNS=no' /etc/sysconfig/network-scripts/ifcfg-enp0s3; then
32 echo "PEERDNS=no" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
33 systemctl restart NetworkManager
36 ##modify /etc/resolv.conf to point to foreman
37 echo "${blue} Configuring resolv.conf with DNS: $dns_server ${reset}"
38 cat > /etc/resolv.conf << EOF
39 search ci.com $domain_name
40 nameserver $dns_server
45 ##modify /etc/hosts to add own IP for rabbitmq workaround
46 host_short_name=`echo $host_name | cut -d . -f 1`
47 echo "${blue} Configuring hosts with: $host_name $host_ip ${reset}"
48 cat > /etc/hosts << EOF
49 $host_ip $host_short_name $host_name
50 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
51 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
54 if ! ping www.google.com -c 5; then
55 echo "${red} No internet connection, check your route and DNS setup ${reset}"
60 if ! yum repolist | grep "epel/"; then
61 if ! rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm; then
62 printf '%s\n' 'vm_provision_nodes.sh: Unable to configure EPEL repo' >&2
66 printf '%s\n' 'vm_nodes_provision.sh: Skipping EPEL repo as it is already configured.'
69 ##install device-mapper-libs
70 ##needed for libvirtd on compute nodes
71 if ! yum -y upgrade device-mapper-libs; then
72 echo "${red} WARN: Unable to upgrade device-mapper-libs...nova-compute may not function ${reset}"
75 echo "${blue} Installing Puppet ${reset}"
77 if ! yum list installed | grep -i puppet; then
78 if ! yum -y install puppet; then
79 printf '%s\n' 'vm_nodes_provision.sh: Unable to install puppet package' >&2
84 echo "${blue} Configuring puppet ${reset}"
85 cat > /etc/puppet/puppet.conf << EOF
88 vardir = /var/lib/puppet
89 logdir = /var/log/puppet
90 rundir = /var/run/puppet
96 ignoreschedules = true
98 ca_server = foreman-server.$domain_name
100 environment = production
101 server = foreman-server.$domain_name
106 # Setup puppet to run on system reboot
107 /sbin/chkconfig --level 345 puppet on
109 /usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server foreman-server.$domain_name --no-daemonize
113 # Inform the build system that we are done.
114 echo "Informing Foreman that we are built"
115 wget -q -O /dev/null --no-check-certificate http://foreman-server.$domain_name:80/unattended/built
117 echo "Starting puppet"
118 systemctl start puppet