summaryrefslogtreecommitdiffstats
path: root/bin/local_apply.sh
blob: 4352839d1a2408131a3d7a9734bc70671ff0a89b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash

# https://tickets.puppetlabs.com/browse/FACT-1289
grep -q 'when /virtualbox/i' /usr/share/ruby/vendor_ruby/facter/virtual.rb
if [ $? -gt 0 ]; then
 pushd /
 rpm -qi patch > /dev/null || puppet resource package patch ensure=installed
 patch -p 0 <<END
--- /usr/share/ruby/vendor_ruby/facter/virtual.rb_old 2015-12-21 17:42:05.909487491 +0100
+++ /usr/share/ruby/vendor_ruby/facter/virtual.rb 2015-12-21 17:40:43.533994750 +0100
@@ -256,6 +256,8 @@
         'xenu'
       when /ibm_systemz/i
         'zlinux'
+      when /virtualbox/i
+        'virtualbox'
       else
         output.to_s.split("\n").last
       end
END
 popd
fi

if [ ! -d /var/lib/puppetdb ]; then
  [ -f /etc/yum.repos.d/puppetlabs.repo ] || rpm -Uvh http://yum.puppetlabs.com/el/7/products/x86_64/puppetlabs-release-7-11.noarch.rpm
  # setup puppetdb & other things for local apply
  puppet apply --parser=future --hiera_config=/etc/puppet/ibox/hieradata/config.yaml --modulepath=/etc/puppet/ibox/modules/public/:/etc/puppet/ibox/modules/ibox/ <<EOF | tee -a /var/log/ibox.log
Exec { path => '/sbin:/usr/bin:/usr/sbin:/bin:/usr/local/bin:/usr/local/sbin', }
exec{'generate_certs':
  command => 'puppet master --masterport 8141; sleep 10; kill \`cat /var/run/puppet/master.pid\`',
  creates => "/var/lib/puppet/ssl/certs/\${::fqdn}.pem",
  before  => Package['puppetdb'],
}
class{'puppetdb::globals':
  version => '2.3.8-1.el7'
}
class{'::puppetdb':
  database        => 'embedded',
  manage_dbserver => false,
  manage_firewall => false,
} -> package {'puppetdb-terminus':
  ensure => installed,
} -> file{'/etc/puppet/puppetdb.conf':
  content => "[main]\nserver = \${::fqdn}\nport = 8081\n",
  notify  => Service['puppetdb'],
} -> file{'/etc/puppet/routes.yaml':
  content => '---
apply:
  catalog:
    terminus: compiler
    cache: puppetdb
  facts:
    terminus: facter
    cache: puppetdb_apply
',
}
ensure_packages(['rubygem-base32'])
include ::motd::puppetmaster
include ::trocla::yaml
include ::trocla::master::hiera
include ::iuid::config
EOF
fi

puppet apply --parser=future --show_diff --hiera_config=/etc/puppet/ibox/hieradata/config.yaml --modulepath=/etc/puppet/ibox/modules/public/:/etc/puppet/ibox/modules/ibox/ --storeconfigs --storeconfigs_backend=puppetdb --report --reports=puppetdb /etc/puppet/ibox/manifests/ $@ | tee -a /var/log/ibox.log