Guest User

Untitled

a guest
Jan 11th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. wget https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb
  2. sudo dpkg -i puppetlabs-release-pc1-xenial.deb
  3. sudo apt-get update
  4.  
  5. sudo apt-get install -y puppetmaster puppet git apache2-utils curl rubygems-integration build-essential libmysqlclient-dev ruby-dev
  6. sudo apt-get install -y puppetdb puppetdb-terminus
  7.  
  8. echo "127.0.0.1 puppet" >> /etc/hosts
  9. echo "127.0.0.1 puppetdb" >> /etc/hosts
  10.  
  11. gem install --no-rdoc --no-ri hiera-mysql hiera-mysql-backend mysql mysql2
  12. cd /etc/puppet
  13.  
  14. ## Setup MYSQL and add hiera user and database
  15. if [ -z ${HIERA_USER_PASSWORD+x} ]; then
  16. HIERA_USER_PASSWORD=`date +%s | sha256sum | base64 | head -c 16`
  17. fi
  18.  
  19. SERVER_FQDN=`facter fqdn`
  20. mysql --defaults-file=/etc/mysql/debian.cnf -e "GRANT USAGE ON *.* TO 'hierauser'@'localhost'; DROP USER 'hierauser'@'localhost';"
  21. mysql --defaults-file=/etc/mysql/debian.cnf -e "CREATE USER 'hierauser'@'localhost' IDENTIFIED BY '${HIERA_USER_PASSWORD}'; GRANT ALL PRIVILEGES ON hiera.* TO 'hierauser'@'localhost';FLUSH PRIVILEGES;"
  22.  
  23. ## Setup PuppetDB
  24. echo "[main]
  25. server = ${SERVER_FQDN}
  26. port = 8081
  27. soft_write_failure = false" > /etc/puppet/puppetdb.conf
  28.  
  29. mkdir -p /etc/puppet/atomia/service_files
  30.  
  31. echo "mod \"atomia\", :git =>\"git://github.com/atomia/puppet-atomia.git\", :ref => \"master\" " > /etc/puppet/Puppetfile
  32.  
  33. cd /etc/puppet
  34.  
  35. gem install --no-rdoc --no-ri librarian-puppet
  36. HOME=/root librarian-puppet install
  37. cp /etc/puppet/modules/atomia/files/default_files/* /etc/puppet/atomia/service_files/
  38.  
  39. mkdir -p /etc/puppet/manifests/
  40. echo "
  41. node default {
  42. hiera_include('classes')
  43. }
  44. " > /etc/puppet/manifests/site.pp
  45.  
  46. echo "---
  47. :backends:
  48. - yaml
  49. - mysql
  50.  
  51. :yaml:
  52. :datadir: /etc/puppet/hieradata
  53.  
  54. :mysql:
  55. :host: localhost
  56. :user: hierauser
  57. :pass: ${HIERA_USER_PASSWORD}
  58. :database: hiera
  59.  
  60. :query: SELECT val FROM configuration WHERE var='%{key}'
  61.  
  62.  
  63. :hierarchy:
  64. - \"%{::atomia_role_1}\"
  65. - \"%{::atomia_role_2}\"
  66. - \"%{::atomia_role_3}\"
  67. - \"%{::atomia_role_4}\"
  68. - \"%{::atomia_role_5}\"
  69. - bootstrap
  70.  
  71. :logger: console
  72. " > /etc/puppet/hiera.yaml
  73.  
  74. echo "[atomiacerts]
  75. path /etc/puppet/atomiacerts
  76. allow *
  77. [atomia]
  78. path /etc/puppet/atomia
  79. allow *" > /etc/puppet/fileserver.conf
  80.  
  81. echo "[main]
  82. logdir=/var/log/puppet
  83. vardir=/var/lib/puppet
  84. ssldir=/var/lib/puppet/ssl
  85. rundir=/var/run/puppet
  86. factpath=$vardir/lib/facter
  87. parser = future
  88.  
  89. [master]
  90. # These are needfed when the puppetmaster is run by passenger
  91. # and can safely be removed if webrick is used.
  92. ssl_client_header = SSL_CLIENT_S_DN
  93. ssl_client_verify_header = SSL_CLIENT_VERIFY
  94. autosign = true
  95. storeconfigs = true
  96. storeconfigs_backend = puppetdb
  97. reports = store,puppetdb" > /etc/puppet/puppet.conf
  98.  
  99. mv modules/atomia/examples/hieradata/ /etc/puppet/hieradata/
  100.  
  101. sudo update-rc.d puppetdb defaults
  102. sudo service puppetdb start
  103.  
  104. /etc/init.d/puppetmaster restart
  105.  
  106. echo "ALL DONE!"
Add Comment
Please, Sign In to add comment