Commit b909db3c authored by Walter Heck's avatar Walter Heck

Renamed the setup.sh script to setup-foss-master.sh

In order to make it easier to recognize over time.
parent 481e6229
......@@ -55,7 +55,7 @@ roles:
foss-puppet-master:
provisioners:
- type: shell
path: files/setup.sh
path: files/setup-foss-master.sh
env:
GIT_BRANCH: <%= ENV['GIT_BRANCH'] %>
OT_DOMAIN: <%= ENV['OT_DOMAIN'] %>
......
......@@ -31,44 +31,44 @@ PUPPET_ENV=$(echo $GIT_BRANCH | sed s'/[-//]/_/g')
log "==> stopping firewalld service" norm
if [ -f /usr/lib/systemd/system/firewalld.service ]; then
service firewalld stop || { log "==> failed to stop firewalld service" err ; exit 1; }
service firewalld stop || { log "==> $SIGN_ERR failed to stop firewalld service" err ; exit 1; }
elif [ -f /usr/lib/systemd/system/iptables.service ]; then
service iptables stop || { log "==> failed to stop iptables service" err; exit 1; }
service iptables stop || { log "==> $SIGN_ERR failed to stop iptables service" err; exit 1; }
else
log "no firewalld or iptables service found" norm
fi
log "==> OK:stopping firewalld service" ok
log "==> $SIGN_OK OK:stopping firewalld service" ok
log "==> installing necessary yum repositories and foreman-installer" norm
if rpm -q puppetlabs-release-pc1-el-7; then
log "==> puppetlabs-release-pc1-el-7 already installed, skipping" norm
else
rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm || { log "==> failed to install puppetlabs pc1 rpm" err; exit 1; }
rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm || { log "==> $SIGN_ERR failed to install puppetlabs pc1 rpm" err; exit 1; }
fi
if rpm -q epel-release; then
log "==> epel-release already installed, skipping" norm
else
yum -y install epel-release || { log "==> failed to install epel-release" err; exit 1; }
yum -y install epel-release || { log "==> $SIGN_ERR failed to install epel-release" err; exit 1; }
fi
if rpm -q foreman-release; then
log "==> foreman-release already installed, skipping" norm
else
yum -y install https://yum.theforeman.org/releases/1.13/el7/x86_64/foreman-release.rpm || { log "==> failed to install foreman-release" err; exit 1; }
yum -y install https://yum.theforeman.org/releases/1.13/el7/x86_64/foreman-release.rpm || { log "==> $SIGN_ERR failed to install foreman-release" err; exit 1; }
fi
if rpm -q foreman-installer; then
log "==> foreman-installer already installed, skipping" norm
else
yum install -y foreman-installer || { log "==> failed to install foreman-installer" err ; exit 1; }
yum install -y foreman-installer || { log "==> $SIGN_ERR failed to install foreman-installer" err ; exit 1; }
fi
log "==> OK:installing necessary yum repositories and foreman-installer" ok
log "==> $SIGN_OK OK:installing necessary yum repositories and foreman-installer" ok
log "==> enabling postgresql repository" norm
echo "postgresql::globals::version: '9.4'" >> /usr/share/foreman-installer/config/foreman.hiera/RedHat.yaml
echo "postgresql::globals::manage_package_repo: true" >> /usr/share/foreman-installer/config/foreman.hiera/RedHat.yaml
log "==> OK:enabling postgresql repository" ok
log "==> $SIGN_OK OK:enabling postgresql repository" ok
log "==> installing puppet and foreman dashboard" norm
foreman-installer \
......@@ -77,7 +77,7 @@ foreman-installer \
--foreman-proxy-dhcp false \
--foreman-proxy-bmc false \
--foreman-proxy-dns false \
--puppet-autosign-entries '*.opstheater.vm' \
--puppet-autosign-entries "*.${OT_DOMAIN}" \
--puppet-environment $PUPPET_ENV \
--foreman-configure-epel-repo false \
--foreman-locations-enabled true \
......@@ -89,7 +89,7 @@ foreman-installer \
--foreman-plugin-puppetdb-dashboard-address http://localhost:8080/pdb/dashboard
CREDENTIALS=$(foreman-installer --no-colors | grep -i "credentials")
log "==> OK:installing puppet and foreman dashboard" ok
log "==> $SIGN_OK OK:installing puppet and foreman dashboard" ok
#fetch server hostname
HOSTNAME=$(/opt/puppetlabs/puppet/bin/facter fqdn)
......@@ -100,10 +100,10 @@ cat <<EOF > /etc/foreman/plugins/default_hostgroup.yaml
---
:default_hostgroup:
:facts_map:
"OpsTheater Infra":
"OpsTheater":
"hostname": ".*"
EOF
log "==> OK:configure default hostgroup plugin" ok
log "==> $SIGN_OK OK:configure default hostgroup plugin" ok
source /etc/profile
......@@ -111,20 +111,20 @@ log "==> installing puppetdb" norm
/opt/puppetlabs/bin/puppet module install puppetlabs/puppetdb || { log "==> $SIGN_ERR failed to install puppetdb puppet module" ; exit 1; }
/opt/puppetlabs/bin/puppet apply -e "class { 'puppetdb': manage_firewall => false} include puppetdb::master::config" --detailed-exitcodes
if [ $? == 4 ] || [ $? == 6 ]; then
log "==> puppet agent run encountered errors" err
log "==> $SIGN_ERR puppet agent run encountered errors" err
exit 1
fi
log "==> OK:installing puppetdb" ok
log "==> $SIGN_OK OK:installing puppetdb" ok
log "==> stopping firewalld service" norm
if [ -f /usr/lib/systemd/system/firewalld.service ]; then
service firewalld stop || { log "==> failed to stop firewalld service" err ; exit 1; }
service firewalld stop || { log "==> $SIGN_ERR failed to stop firewalld service" err ; exit 1; }
elif [ -f /usr/lib/systemd/system/iptables.service ]; then
service iptables stop || { log "==> failed to stop iptables service" err; exit 1; }
service iptables stop || { log "==> $SIGN_ERR failed to stop iptables service" err; exit 1; }
else
log "no firewalld or iptables service found" norm
fi
log "==> OK:stopping firewalld service" ok
log "==> $SIGN_OK OK:stopping firewalld service" ok
log "==> configuring R10K" norm
/opt/puppetlabs/bin/puppet module install zack/r10k || { log "==> $SIGN_ERR failed to install r10k puppet module" ; exit 1; }
......@@ -141,32 +141,39 @@ if [ $? == 4 ] || [ $? == 6 ]; then
log "==> puppet apply run encountered errors" err
exit 1
fi
log "==> OK:configuring R10K" ok
log "==> $SIGN_OK OK:configuring R10K" ok
log "==> deploying r10k environments" norm
# always check out production (it contains the hiera.yaml file), but possibly also the current branch
/opt/puppetlabs/puppet/bin/r10k deploy environment production $GIT_BRANCH -pv debug
log "==> OK:deploying r10k environments" ok
log "==> $SIGN_OK OK:deploying r10k environments" ok
log "==> importing puppet environments to foreman" norm
hammer proxy import-classes --id 1
if [ $? == 1 ]; then
log "==> importing classed encountered errors" err
log "==> $SIGN_ERR importing classed encountered errors" err
exit 1
fi
log "==> OK:importing puppet environments to foreman" ok
log "==> $SIGN_OK OK:importing puppet environments to foreman" ok
log "==> creating default hostgroup" norm
hammer hostgroup create --name "OpsTheater Infra" --puppet-proxy-id 1 --puppet-ca-proxy-id 1 --environment $PUPPET_ENV --locations Global --organizations OpsTheater
log "==> OK:creating default hostgroup" ok
log "==> creating default hostgroups" norm
hammer hostgroup create --name "OpsTheater" --puppet-proxy-id 1 --puppet-ca-proxy-id 1 --environment $PUPPET_ENV --locations Global --organizations OpsTheater
hammer hostgroup create --name "Elastic" --parent "OpsTheater" --puppet-classes "opstheater::role::elastic::server"
hammer hostgroup create --name "MySQL" --parent "OpsTheater" --puppet-classes "opstheater::role::database::standalone"
hammer hostgroup create --name "Icinga" --parent "OpsTheater" --puppet-classes "opstheater::role::monitoring::standalone"
hammer hostgroup create --name "Gitlab" --parent "OpsTheater" --puppet-classes "opstheater::role::gitlab::server"
hammer hostgroup create --name "Puppet" --parent "OpsTheater" --puppet-classes "opstheater::role::puppet::master"
log "==> $SIGN_OK OK:creating default hostgroup" ok
hammer organization update --name OpsTheater --environments $PUPPET_ENV
hammer location update --name Global --environments $PUPPET_ENV
hammer host update --name $HOSTNAME --hostgroup 'OpsTheater Infra' --organization OpsTheater --location Global
hammer host update --name $HOSTNAME --hostgroup 'OpsTheater/Puppet' --organization OpsTheater --location Global
hammer user create --admin true --firstname api --lastname user --locations Global --organizations OpsTheater --login opstheater --password opstheater --mail api@opstheater.com --auth-source-id 1
log "==> configuring hiera.yaml" norm
/opt/puppetlabs/bin/puppet config set hiera_config /etc/puppetlabs/code/environments/production/hiera.yaml
log "==> OK:configuring hiera.yaml" ok
log "==> $SIGN_OK OK:configuring hiera.yaml" ok
service httpd restart
service puppetserver restart
......@@ -174,10 +181,10 @@ service puppetserver restart
log "==> running puppet agent" norm
/opt/puppetlabs/bin/puppet agent -t --detailed-exitcodes
if [ $? == 4 ] || [ $? == 6 ]; then
log "==> puppet agent run encountered errors" err
log "==> $SIGN_ERR puppet agent run encountered errors" err
exit 1
fi
log "==> OK: running puppet agent" ok
log "==> $SIGN_OK OK: running puppet agent" ok
/opt/puppetlabs/bin/puppet resource service firewalld ensure=stopped enable=false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment