Guest User

Untitled

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