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
25 echo "${blue} Setting Hostname ${reset}"
26 hostnamectl set-hostname $host_name
29 echo "${blue} Removing DNS server on first interface ${reset}"
30 if ! grep 'PEERDNS=no' /etc/sysconfig/network-scripts/ifcfg-enp0s3; then
31 echo "PEERDNS=no" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
32 systemctl restart NetworkManager
35 ##modify /etc/resolv.conf to point to foreman
36 echo "${blue} Configuring resolv.conf with DNS: $dns_server ${reset}"
37 cat > /etc/resolv.conf << EOF
38 search ci.com opnfv.com
39 nameserver $dns_server
44 ##modify /etc/hosts to add own IP for rabbitmq workaround
45 host_short_name=`echo $host_name | cut -d . -f 1`
46 echo "${blue} Configuring hosts with: $host_name $host_ip ${reset}"
47 cat > /etc/hosts << EOF
48 $host_ip $host_short_name $host_name
49 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
50 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
53 if ! ping www.google.com -c 5; then
54 echo "${red} No internet connection, check your route and DNS setup ${reset}"
59 if ! yum repolist | grep "epel/"; then
60 if ! rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm; then
61 printf '%s\n' 'vm_provision_nodes.sh: Unable to configure EPEL repo' >&2
65 printf '%s\n' 'vm_nodes_provision.sh: Skipping EPEL repo as it is already configured.'
68 ##install device-mapper-libs
69 ##needed for libvirtd on compute nodes
70 if ! yum -y upgrade device-mapper-libs; then
71 echo "${red} WARN: Unable to upgrade device-mapper-libs...nova-compute may not function ${reset}"
74 echo "${blue} Installing Puppet ${reset}"
76 if ! yum list installed | grep -i puppet; then
77 if ! yum -y install puppet; then
78 printf '%s\n' 'vm_nodes_provision.sh: Unable to install puppet package' >&2
83 echo "${blue} Configuring puppet ${reset}"
84 cat > /etc/puppet/puppet.conf << EOF
87 vardir = /var/lib/puppet
88 logdir = /var/log/puppet
89 rundir = /var/run/puppet
95 ignoreschedules = true
97 ca_server = foreman-server.opnfv.com
99 environment = production
100 server = foreman-server.opnfv.com
105 # Setup puppet to run on system reboot
106 /sbin/chkconfig --level 345 puppet on
108 /usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server foreman-server.opnfv.com --no-daemonize
112 # Inform the build system that we are done.
113 echo "Informing Foreman that we are built"
114 wget -q -O /dev/null --no-check-certificate http://foreman-server.opnfv.com:80/unattended/built
116 echo "Starting puppet"
117 systemctl start puppet