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
24 echo "${blue} Setting Hostname ${reset}"
25 hostnamectl set-hostname $host_name
28 echo "${blue} Removing DNS server on first interface ${reset}"
29 if ! grep 'PEERDNS=no' /etc/sysconfig/network-scripts/ifcfg-enp0s3; then
30 echo "PEERDNS=no" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
31 systemctl restart NetworkManager
34 if ! ping www.google.com -c 5; then
35 echo "${red} No internet connection, check your route and DNS setup ${reset}"
40 if ! yum repolist | grep "epel/"; then
41 if ! rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm; then
42 printf '%s\n' 'vm_provision_nodes.sh: Unable to configure EPEL repo' >&2
46 printf '%s\n' 'vm_nodes_provision.sh: Skipping EPEL repo as it is already configured.'
49 ##install device-mapper-libs
50 ##needed for libvirtd on compute nodes
51 if ! yum -y upgrade device-mapper-libs; then
52 echo "${red} WARN: Unable to upgrade device-mapper-libs...nova-compute may not function ${reset}"
55 echo "${blue} Installing Puppet ${reset}"
57 if ! yum list installed | grep -i puppet; then
58 if ! yum -y install puppet; then
59 printf '%s\n' 'vm_nodes_provision.sh: Unable to install puppet package' >&2
64 echo "${blue} Configuring puppet ${reset}"
65 cat > /etc/puppet/puppet.conf << EOF
68 vardir = /var/lib/puppet
69 logdir = /var/log/puppet
70 rundir = /var/run/puppet
76 ignoreschedules = true
78 ca_server = foreman-server.opnfv.com
80 environment = production
81 server = foreman-server.opnfv.com
86 # Setup puppet to run on system reboot
87 /sbin/chkconfig --level 345 puppet on
89 /usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server foreman-server.opnfv.com --no-daemonize
93 # Inform the build system that we are done.
94 echo "Informing Foreman that we are built"
95 wget -q -O /dev/null --no-check-certificate http://foreman-server.opnfv.com:80/unattended/built
97 echo "Starting puppet"
98 systemctl start puppet