Guest User

Untitled

a guest
Jun 24th, 2017
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #param1 = hostname de la console (devops-VirtualBox)
  4. #param2 = ip de la console (10.0.2.15)
  5.  
  6. #Etre sur que la vm est a jour
  7. apt-get update
  8. apt-get upgrade
  9.  
  10. #Setter le host name de la machine au parametre specifier (param1)
  11. hostnamectl set-hostname $1
  12.  
  13. #Modifier le hosts file
  14. echo "$2 $1" >> /etc/hosts
  15.  
  16. #Installer wget si il nest pas installer
  17. wgetinstalled=`apt-cache policy wget | wc -l`
  18. if [ $wgetinstalled == 0 ]
  19. then
  20. echo "Installing wget..."
  21. apt-get install wget
  22. fi
  23.  
  24.  
  25.  
  26.  
  27. distro=`head -n 1 /etc/os-release | cut -d "=" -f 2`
  28. if [[ $distro == *"Ubuntu"* ]]; then
  29. #Executer ca si on est sur Ubuntu
  30.  
  31. #Downloader le package dinstallation de chef server ubuntu
  32. wget https://packages.chef.io/files/stable/chef-server/12.15.7/ubuntu/16.04/chef-server-core_12.15.7-1_amd64.deb -O /root/chef.deb
  33.  
  34. #Executer le package dinstallation
  35. dpkg -i /root/chef.deb
  36.  
  37. ####################################
  38.  
  39. elif [[ $distro == *"CentOS"* ]]; then
  40. #Executer ca si on est sur Centos 7
  41.  
  42. #Downloader le package dinstallation de chef server centos 7
  43. wget https://packages.chef.io/files/stable/chef-server/12.15.7/el/7/chef-server-core-12.15.7-1.el7.x86_64.rpm -O /root/chef.rpm
  44.  
  45. #Executer le package dinstallation
  46. rpm -i /root/chef.rpm
  47.  
  48. ####################################
  49. fi
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. #Install la console web de chef
  58. chef-server-ctl install chef-manage
  59.  
  60. #reconfigure le server
  61. chef-server-ctl reconfigure --accept-license
  62.  
  63. #reconfigure la console web
  64. chef-manage-ctl reconfigure --accept-license
  65.  
  66.  
  67. #Ici il faut ajouter le user a la console de management
  68. chef-server-ctl user-create chef chef chef chef@chef.com qwerty -f /root/admin.pem
  69.  
  70. #Creer lorganisation ici
  71. chef-server-ctl org-create chef chef --association_user chef -f /root/org.pem
  72.  
  73.  
  74. #Testing
  75. chef-server-ctl test
  76.  
  77.  
  78. echo "You can connect to the web console at : http://$2 with the credentials : username:chef password:qwerty "
Add Comment
Please, Sign In to add comment