cloud-mu 1.9.0.pre.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Berksfile +56 -0
- data/Berksfile.lock +250 -0
- data/Jenkinsfile +184 -0
- data/LICENSE.md +37 -0
- data/README.md +26 -0
- data/bin/mu-aws-setup +376 -0
- data/bin/mu-cleanup +68 -0
- data/bin/mu-configure +1133 -0
- data/bin/mu-deploy +166 -0
- data/bin/mu-firewall-allow-clients +30 -0
- data/bin/mu-gcp-setup +200 -0
- data/bin/mu-gen-docs +34 -0
- data/bin/mu-gen-env +42 -0
- data/bin/mu-load-config.rb +158 -0
- data/bin/mu-node-manage +683 -0
- data/bin/mu-self-update +228 -0
- data/bin/mu-ssh +23 -0
- data/bin/mu-tunnel-nagios +144 -0
- data/bin/mu-upload-chef-artifacts +757 -0
- data/bin/mu-user-manage +275 -0
- data/cookbooks/awscli/LICENSE +37 -0
- data/cookbooks/awscli/README.md +58 -0
- data/cookbooks/awscli/attributes/default.rb +1 -0
- data/cookbooks/awscli/libraries/instance_metadata.rb +21 -0
- data/cookbooks/awscli/metadata.rb +20 -0
- data/cookbooks/awscli/recipes/default.rb +56 -0
- data/cookbooks/awscli/templates/default/config.erb +18 -0
- data/cookbooks/mu-activedirectory/CHANGELOG.md +13 -0
- data/cookbooks/mu-activedirectory/LICENSE +37 -0
- data/cookbooks/mu-activedirectory/README.md +6 -0
- data/cookbooks/mu-activedirectory/attributes/default.rb +98 -0
- data/cookbooks/mu-activedirectory/files/default/password-auth +32 -0
- data/cookbooks/mu-activedirectory/files/default/sshd_pol.pp +0 -0
- data/cookbooks/mu-activedirectory/files/default/sshd_pol.te +32 -0
- data/cookbooks/mu-activedirectory/files/default/syslogd_oddjobd.pp +0 -0
- data/cookbooks/mu-activedirectory/files/default/syslogd_oddjobd.te +10 -0
- data/cookbooks/mu-activedirectory/files/default/system-auth +34 -0
- data/cookbooks/mu-activedirectory/files/default/winbindpol.pp +0 -0
- data/cookbooks/mu-activedirectory/files/default/winbindpol.te +37 -0
- data/cookbooks/mu-activedirectory/libraries/config.rb +106 -0
- data/cookbooks/mu-activedirectory/libraries/helper.rb +86 -0
- data/cookbooks/mu-activedirectory/metadata.rb +17 -0
- data/cookbooks/mu-activedirectory/providers/domain.rb +152 -0
- data/cookbooks/mu-activedirectory/providers/domain_controller.rb +89 -0
- data/cookbooks/mu-activedirectory/providers/domain_node.rb +275 -0
- data/cookbooks/mu-activedirectory/recipes/default.rb +8 -0
- data/cookbooks/mu-activedirectory/recipes/domain-controller.rb +44 -0
- data/cookbooks/mu-activedirectory/recipes/domain-node.rb +50 -0
- data/cookbooks/mu-activedirectory/recipes/domain.rb +43 -0
- data/cookbooks/mu-activedirectory/recipes/sssd.rb +185 -0
- data/cookbooks/mu-activedirectory/resources/domain.rb +25 -0
- data/cookbooks/mu-activedirectory/resources/domain_controller.rb +25 -0
- data/cookbooks/mu-activedirectory/resources/domain_node.rb +20 -0
- data/cookbooks/mu-activedirectory/templates/default/dhclient-eth0.conf.erb +4 -0
- data/cookbooks/mu-activedirectory/templates/default/interface +0 -0
- data/cookbooks/mu-activedirectory/templates/default/krb5.conf.erb +23 -0
- data/cookbooks/mu-activedirectory/templates/default/ntp.conf.erb +56 -0
- data/cookbooks/mu-activedirectory/templates/default/smb.conf.erb +33 -0
- data/cookbooks/mu-activedirectory/templates/default/sssd.conf.erb +60 -0
- data/cookbooks/mu-activedirectory/templates/windows/Backup.xml.erb +20 -0
- data/cookbooks/mu-activedirectory/templates/windows/bkupInfo.xml.erb +1 -0
- data/cookbooks/mu-activedirectory/templates/windows/gpreprt.xml.erb +198 -0
- data/cookbooks/mu-activedirectory/templates/windows/gptmpl.inf.erb +12 -0
- data/cookbooks/mu-activedirectory/templates/windows/manifest.xml.erb +1 -0
- data/cookbooks/mu-firewall/CHANGELOG.md +11 -0
- data/cookbooks/mu-firewall/LICENSE +37 -0
- data/cookbooks/mu-firewall/README.md +5 -0
- data/cookbooks/mu-firewall/attributes/default.rb +3 -0
- data/cookbooks/mu-firewall/metadata.rb +16 -0
- data/cookbooks/mu-firewall/recipes/default.rb +10 -0
- data/cookbooks/mu-glusterfs/CHANGELOG.md +13 -0
- data/cookbooks/mu-glusterfs/LICENSE +37 -0
- data/cookbooks/mu-glusterfs/README.md +5 -0
- data/cookbooks/mu-glusterfs/attributes/default.rb +34 -0
- data/cookbooks/mu-glusterfs/metadata.rb +17 -0
- data/cookbooks/mu-glusterfs/recipes/client.rb +62 -0
- data/cookbooks/mu-glusterfs/recipes/default.rb +16 -0
- data/cookbooks/mu-glusterfs/recipes/samba.rb +57 -0
- data/cookbooks/mu-glusterfs/recipes/server.rb +200 -0
- data/cookbooks/mu-glusterfs/templates/default/mu-gluster-client.erb +71 -0
- data/cookbooks/mu-glusterfs/templates/default/smb.conf.erb +14 -0
- data/cookbooks/mu-jenkins/CHANGELOG.md +13 -0
- data/cookbooks/mu-jenkins/LICENSE +37 -0
- data/cookbooks/mu-jenkins/README.md +105 -0
- data/cookbooks/mu-jenkins/attributes/default.rb +42 -0
- data/cookbooks/mu-jenkins/files/default/cleanup_deploy_config.xml +73 -0
- data/cookbooks/mu-jenkins/files/default/deploy_config.xml +44 -0
- data/cookbooks/mu-jenkins/metadata.rb +21 -0
- data/cookbooks/mu-jenkins/recipes/default.rb +195 -0
- data/cookbooks/mu-jenkins/recipes/node-ssh-config.rb +54 -0
- data/cookbooks/mu-jenkins/recipes/public_key.rb +24 -0
- data/cookbooks/mu-jenkins/templates/default/example_job.config.xml.erb +24 -0
- data/cookbooks/mu-jenkins/templates/default/org.jvnet.hudson.plugins.SSHBuildWrapper.xml.erb +14 -0
- data/cookbooks/mu-jenkins/templates/default/ssh_config.erb +6 -0
- data/cookbooks/mu-master/CHANGELOG.md +13 -0
- data/cookbooks/mu-master/LICENSE +37 -0
- data/cookbooks/mu-master/README.md +6 -0
- data/cookbooks/mu-master/attributes/default.rb +95 -0
- data/cookbooks/mu-master/files/default/0-mu-log-server.conf +19 -0
- data/cookbooks/mu-master/files/default/addRSA.ldif +8 -0
- data/cookbooks/mu-master/files/default/check_mem.pl +197 -0
- data/cookbooks/mu-master/files/default/cloudamatic.png +0 -0
- data/cookbooks/mu-master/files/default/dirsrv_admin.pp +0 -0
- data/cookbooks/mu-master/files/default/dirsrv_admin.te +13 -0
- data/cookbooks/mu-master/files/default/nagios_selinux.pp +0 -0
- data/cookbooks/mu-master/files/default/nagios_selinux.te +51 -0
- data/cookbooks/mu-master/files/default/nagios_selinux_7.pp +0 -0
- data/cookbooks/mu-master/files/default/nagios_selinux_7.te +17 -0
- data/cookbooks/mu-master/files/default/pam_sshd +18 -0
- data/cookbooks/mu-master/files/default/ssl_enable.ldif +18 -0
- data/cookbooks/mu-master/files/default/syslogd_oddjobd.pp +0 -0
- data/cookbooks/mu-master/files/default/syslogd_oddjobd.te +10 -0
- data/cookbooks/mu-master/files/default/vimrc +19 -0
- data/cookbooks/mu-master/libraries/mu.rb +29 -0
- data/cookbooks/mu-master/metadata.rb +30 -0
- data/cookbooks/mu-master/providers/user.rb +41 -0
- data/cookbooks/mu-master/recipes/389ds.rb +164 -0
- data/cookbooks/mu-master/recipes/basepackages.rb +58 -0
- data/cookbooks/mu-master/recipes/caching_nameserver.rb +37 -0
- data/cookbooks/mu-master/recipes/default.rb +451 -0
- data/cookbooks/mu-master/recipes/eks-kubectl.rb +41 -0
- data/cookbooks/mu-master/recipes/firewall-holes.rb +70 -0
- data/cookbooks/mu-master/recipes/init.rb +542 -0
- data/cookbooks/mu-master/recipes/ssl-certs.rb +109 -0
- data/cookbooks/mu-master/recipes/sssd.rb +89 -0
- data/cookbooks/mu-master/recipes/update_nagios_only.rb +242 -0
- data/cookbooks/mu-master/recipes/vault.rb +111 -0
- data/cookbooks/mu-master/resources/user.rb +19 -0
- data/cookbooks/mu-master/templates/default/389-directory-setup.inf.erb +28 -0
- data/cookbooks/mu-master/templates/default/chef-server.rb.erb +18 -0
- data/cookbooks/mu-master/templates/default/dhclient-eth0.conf.erb +9 -0
- data/cookbooks/mu-master/templates/default/mu-momma-cat.erb +149 -0
- data/cookbooks/mu-master/templates/default/mu.rc.erb +9 -0
- data/cookbooks/mu-master/templates/default/openssl.cnf.erb +354 -0
- data/cookbooks/mu-master/templates/default/sssd.conf.erb +44 -0
- data/cookbooks/mu-master/templates/default/web_app.conf.erb +90 -0
- data/cookbooks/mu-mongo/CHANGELOG.md +13 -0
- data/cookbooks/mu-mongo/LICENSE +37 -0
- data/cookbooks/mu-mongo/README.md +5 -0
- data/cookbooks/mu-mongo/attributes/default.rb +22 -0
- data/cookbooks/mu-mongo/files/default/keyfile +16 -0
- data/cookbooks/mu-mongo/files/default/remove_nodes.js +5 -0
- data/cookbooks/mu-mongo/metadata.rb +17 -0
- data/cookbooks/mu-mongo/recipes/default.rb +149 -0
- data/cookbooks/mu-mongo/recipes/yum-update-rule.rb +18 -0
- data/cookbooks/mu-mongo/templates/default/mongo_create_openfema_db.js.erb +2 -0
- data/cookbooks/mu-mongo/templates/default/mongo_init.js.erb +1 -0
- data/cookbooks/mu-mongo/templates/default/mongo_logrotate.erb +14 -0
- data/cookbooks/mu-mongo/templates/default/mongo_replset_addnodes.js.erb +6 -0
- data/cookbooks/mu-mongo/templates/default/replset_init.js.erb +2 -0
- data/cookbooks/mu-openvpn/CHANGELOG.md +13 -0
- data/cookbooks/mu-openvpn/LICENSE +37 -0
- data/cookbooks/mu-openvpn/README.md +6 -0
- data/cookbooks/mu-openvpn/attributes/default.rb +119 -0
- data/cookbooks/mu-openvpn/metadata.rb +18 -0
- data/cookbooks/mu-openvpn/recipes/default.rb +108 -0
- data/cookbooks/mu-openvpn/templates/default/users.json.erb +42 -0
- data/cookbooks/mu-php54/CHANGELOG.md +12 -0
- data/cookbooks/mu-php54/LICENSE +37 -0
- data/cookbooks/mu-php54/README.md +0 -0
- data/cookbooks/mu-php54/files/centos/php.ini +1802 -0
- data/cookbooks/mu-php54/files/ubuntu/php.ini +1870 -0
- data/cookbooks/mu-php54/metadata.rb +21 -0
- data/cookbooks/mu-php54/recipes/default.rb +97 -0
- data/cookbooks/mu-splunk/CHANGELOG.md +37 -0
- data/cookbooks/mu-splunk/LICENSE +37 -0
- data/cookbooks/mu-splunk/README.md +451 -0
- data/cookbooks/mu-splunk/attributes/default.rb +95 -0
- data/cookbooks/mu-splunk/attributes/upgrade.rb +49 -0
- data/cookbooks/mu-splunk/definitions/splunk_installer.rb +103 -0
- data/cookbooks/mu-splunk/files/default/splunk-nocheck +10 -0
- data/cookbooks/mu-splunk/libraries/helpers.rb +72 -0
- data/cookbooks/mu-splunk/libraries/splunk_app_provider.rb +156 -0
- data/cookbooks/mu-splunk/libraries/splunk_app_resource.rb +43 -0
- data/cookbooks/mu-splunk/metadata.json +30 -0
- data/cookbooks/mu-splunk/metadata.rb +17 -0
- data/cookbooks/mu-splunk/recipes/client.rb +143 -0
- data/cookbooks/mu-splunk/recipes/default.rb +31 -0
- data/cookbooks/mu-splunk/recipes/disabled.rb +41 -0
- data/cookbooks/mu-splunk/recipes/install_forwarder.rb +23 -0
- data/cookbooks/mu-splunk/recipes/install_server.rb +23 -0
- data/cookbooks/mu-splunk/recipes/server.rb +53 -0
- data/cookbooks/mu-splunk/recipes/service.rb +95 -0
- data/cookbooks/mu-splunk/recipes/setup_auth.rb +49 -0
- data/cookbooks/mu-splunk/recipes/setup_ssl.rb +63 -0
- data/cookbooks/mu-splunk/recipes/upgrade.rb +94 -0
- data/cookbooks/mu-splunk/recipes/user.rb +34 -0
- data/cookbooks/mu-splunk/templates/default/base_logs_unix_inputs.conf.erb +26 -0
- data/cookbooks/mu-splunk/templates/default/inputs.conf.erb +13 -0
- data/cookbooks/mu-splunk/templates/default/outputs.conf.erb +9 -0
- data/cookbooks/mu-splunk/templates/default/splunk-init.erb +74 -0
- data/cookbooks/mu-splunk/templates/default/system-web.conf.erb +7 -0
- data/cookbooks/mu-tools/CHANGELOG.md +12 -0
- data/cookbooks/mu-tools/LICENSE +37 -0
- data/cookbooks/mu-tools/README.md +188 -0
- data/cookbooks/mu-tools/attributes/default.rb +142 -0
- data/cookbooks/mu-tools/attributes/ebs_rolling_snapshots.rb +3 -0
- data/cookbooks/mu-tools/files/amazon/etc/freshclam.conf +235 -0
- data/cookbooks/mu-tools/files/centos/CentOS-Base.repo +52 -0
- data/cookbooks/mu-tools/files/centos/etc/bashrc +93 -0
- data/cookbooks/mu-tools/files/centos/etc/freshclam.conf +235 -0
- data/cookbooks/mu-tools/files/centos/etc/login.defs +72 -0
- data/cookbooks/mu-tools/files/centos/etc/profile +77 -0
- data/cookbooks/mu-tools/files/centos/etc/security/limits.conf +57 -0
- data/cookbooks/mu-tools/files/centos/etc/sysconfig/init +19 -0
- data/cookbooks/mu-tools/files/centos/etc/sysctl.conf +82 -0
- data/cookbooks/mu-tools/files/centos-6/README_MU +0 -0
- data/cookbooks/mu-tools/files/centos-6/etc/audit/stig.rules +173 -0
- data/cookbooks/mu-tools/files/centos-6/etc/bashrc +90 -0
- data/cookbooks/mu-tools/files/centos-6/etc/login.defs +70 -0
- data/cookbooks/mu-tools/files/centos-6/etc/pam.d/su +12 -0
- data/cookbooks/mu-tools/files/centos-6/etc/profile +83 -0
- data/cookbooks/mu-tools/files/centos-6/etc/securetty +12 -0
- data/cookbooks/mu-tools/files/centos-6/etc/sysconfig/init +30 -0
- data/cookbooks/mu-tools/files/centos-6/etc/sysctl.conf +40 -0
- data/cookbooks/mu-tools/files/default/Mu_CA.pem +34 -0
- data/cookbooks/mu-tools/files/default/PSWindowsUpdate.zip +0 -0
- data/cookbooks/mu-tools/files/default/ebs_snapshots.py +123 -0
- data/cookbooks/mu-tools/files/default/etc/BANNER +0 -0
- data/cookbooks/mu-tools/files/default/etc/BANNER-FEDERAL +19 -0
- data/cookbooks/mu-tools/files/default/gpo_no_uac.zip +0 -0
- data/cookbooks/mu-tools/files/default/mypol.pp +0 -0
- data/cookbooks/mu-tools/files/default/mypol.te +37 -0
- data/cookbooks/mu-tools/files/default/nrpe_c7.pp +0 -0
- data/cookbooks/mu-tools/files/default/nrpe_c7.te +31 -0
- data/cookbooks/mu-tools/files/default/nrpe_check_disk.pp +0 -0
- data/cookbooks/mu-tools/files/default/nrpe_check_disk.te +11 -0
- data/cookbooks/mu-tools/files/default/nrpe_disk.pp +0 -0
- data/cookbooks/mu-tools/files/default/nrpe_disk.te +10 -0
- data/cookbooks/mu-tools/files/default/nrpe_file.pp +0 -0
- data/cookbooks/mu-tools/files/default/nrpe_file.te +31 -0
- data/cookbooks/mu-tools/files/default/ntrights +0 -0
- data/cookbooks/mu-tools/files/default/serverclass.conf +18 -0
- data/cookbooks/mu-tools/files/default/splunk-apps/base_logs_unix/local/app.conf +1 -0
- data/cookbooks/mu-tools/files/default/splunk-apps/base_logs_unix/local/inputs.conf +13 -0
- data/cookbooks/mu-tools/files/default/splunk-apps/base_logs_windows/local/app.conf +1 -0
- data/cookbooks/mu-tools/files/default/splunk-apps/base_logs_windows/local/inputs.conf +8 -0
- data/cookbooks/mu-tools/files/default/sshd_pol.pp +0 -0
- data/cookbooks/mu-tools/files/default/sshd_pol.te +32 -0
- data/cookbooks/mu-tools/files/redhat/etc/bashrc +93 -0
- data/cookbooks/mu-tools/files/redhat/etc/freshclam.conf +235 -0
- data/cookbooks/mu-tools/files/redhat/etc/login.defs +72 -0
- data/cookbooks/mu-tools/files/redhat/etc/profile +77 -0
- data/cookbooks/mu-tools/files/redhat/etc/security/limits.conf +57 -0
- data/cookbooks/mu-tools/files/redhat/etc/sysconfig/init +19 -0
- data/cookbooks/mu-tools/files/redhat/etc/sysctl.conf +82 -0
- data/cookbooks/mu-tools/files/redhat-6/README_MU +0 -0
- data/cookbooks/mu-tools/files/redhat-6/etc/audit/stig.rules +173 -0
- data/cookbooks/mu-tools/files/redhat-6/etc/bashrc +90 -0
- data/cookbooks/mu-tools/files/redhat-6/etc/login.defs +70 -0
- data/cookbooks/mu-tools/files/redhat-6/etc/pam.d/su +12 -0
- data/cookbooks/mu-tools/files/redhat-6/etc/profile +83 -0
- data/cookbooks/mu-tools/files/redhat-6/etc/securetty +12 -0
- data/cookbooks/mu-tools/files/redhat-6/etc/sysconfig/init +30 -0
- data/cookbooks/mu-tools/files/redhat-6/etc/sysctl.conf +40 -0
- data/cookbooks/mu-tools/files/redhat-7.1/etc/freshclam.conf +235 -0
- data/cookbooks/mu-tools/files/ubuntu-12.04/etc/bash.bashrc +64 -0
- data/cookbooks/mu-tools/files/ubuntu-12.04/etc/common-session +30 -0
- data/cookbooks/mu-tools/files/ubuntu-12.04/etc/login.defs +338 -0
- data/cookbooks/mu-tools/files/ubuntu-12.04/etc/profile +30 -0
- data/cookbooks/mu-tools/files/ubuntu-12.04/etc/security/limits.conf +56 -0
- data/cookbooks/mu-tools/files/ubuntu-12.04/etc/sysctl.conf +60 -0
- data/cookbooks/mu-tools/libraries/helper.rb +292 -0
- data/cookbooks/mu-tools/metadata.rb +28 -0
- data/cookbooks/mu-tools/recipes/add_admin_ssh_keys.rb +35 -0
- data/cookbooks/mu-tools/recipes/apply_security.rb +440 -0
- data/cookbooks/mu-tools/recipes/aws_api.rb +23 -0
- data/cookbooks/mu-tools/recipes/base_repositories.rb +31 -0
- data/cookbooks/mu-tools/recipes/cisbenchmark.rb +59 -0
- data/cookbooks/mu-tools/recipes/clamav.rb +53 -0
- data/cookbooks/mu-tools/recipes/cloudinit.rb +58 -0
- data/cookbooks/mu-tools/recipes/configure_oracle_tools.rb +81 -0
- data/cookbooks/mu-tools/recipes/disable-requiretty.rb +22 -0
- data/cookbooks/mu-tools/recipes/ebs_rolling_snapshots.rb +75 -0
- data/cookbooks/mu-tools/recipes/efs.rb +70 -0
- data/cookbooks/mu-tools/recipes/eks.rb +160 -0
- data/cookbooks/mu-tools/recipes/gcloud.rb +98 -0
- data/cookbooks/mu-tools/recipes/google_api.rb +25 -0
- data/cookbooks/mu-tools/recipes/maldet.rb +67 -0
- data/cookbooks/mu-tools/recipes/nagios.rb +19 -0
- data/cookbooks/mu-tools/recipes/newclient.rb +23 -0
- data/cookbooks/mu-tools/recipes/nrpe.rb +115 -0
- data/cookbooks/mu-tools/recipes/python_pip.rb +35 -0
- data/cookbooks/mu-tools/recipes/retrieve_application.rb +51 -0
- data/cookbooks/mu-tools/recipes/rsyslog.rb +65 -0
- data/cookbooks/mu-tools/recipes/set_local_fw.rb +57 -0
- data/cookbooks/mu-tools/recipes/set_mu_hostname.rb +81 -0
- data/cookbooks/mu-tools/recipes/split_var_partitions.rb +86 -0
- data/cookbooks/mu-tools/recipes/splunk-client.rb +69 -0
- data/cookbooks/mu-tools/recipes/splunk-server.rb +104 -0
- data/cookbooks/mu-tools/recipes/store_inspec_attr.rb +8 -0
- data/cookbooks/mu-tools/recipes/updates.rb +96 -0
- data/cookbooks/mu-tools/recipes/windows-client.rb +202 -0
- data/cookbooks/mu-tools/resources/aws_windows.rb +33 -0
- data/cookbooks/mu-tools/resources/disk.rb +88 -0
- data/cookbooks/mu-tools/resources/mommacat_request.rb +11 -0
- data/cookbooks/mu-tools/resources/scheduled_tasks.rb +29 -0
- data/cookbooks/mu-tools/resources/sshd_service.rb +45 -0
- data/cookbooks/mu-tools/resources/windows_users.rb +242 -0
- data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +168 -0
- data/cookbooks/mu-tools/templates/centos-6/sshd_config.erb +212 -0
- data/cookbooks/mu-tools/templates/centos-7/sshd_config.erb +215 -0
- data/cookbooks/mu-tools/templates/default/0-mu-log-client.conf.erb +13 -0
- data/cookbooks/mu-tools/templates/default/conf.maldet.erb +137 -0
- data/cookbooks/mu-tools/templates/default/etc_hosts.erb +30 -0
- data/cookbooks/mu-tools/templates/default/etc_pamd_password-auth.erb +14 -0
- data/cookbooks/mu-tools/templates/default/etc_pamd_system-auth.erb +14 -0
- data/cookbooks/mu-tools/templates/default/etc_sysconfig_network.erb +12 -0
- data/cookbooks/mu-tools/templates/default/kubeconfig.erb +29 -0
- data/cookbooks/mu-tools/templates/default/kubelet.service.erb +35 -0
- data/cookbooks/mu-tools/templates/default/maldet_scanall.sh.erb +15 -0
- data/cookbooks/mu-tools/templates/default/nrpe.cfg.erb +233 -0
- data/cookbooks/mu-tools/templates/redhat-6/sshd_config.erb +213 -0
- data/cookbooks/mu-tools/templates/redhat-7/sshd_config.erb +215 -0
- data/cookbooks/mu-tools/templates/ubuntu-12.04/sshd_config.erb +146 -0
- data/cookbooks/mu-tools/templates/ubuntu-14.04/sshd_config.erb +145 -0
- data/cookbooks/mu-tools/templates/windows/Backup.xml.erb +20 -0
- data/cookbooks/mu-tools/templates/windows/bkupInfo.xml.erb +1 -0
- data/cookbooks/mu-tools/templates/windows/gpreprt.xml.erb +214 -0
- data/cookbooks/mu-tools/templates/windows/gptmpl.inf.erb +12 -0
- data/cookbooks/mu-tools/templates/windows/manifest.xml.erb +1 -0
- data/cookbooks/mu-tools/templates/windows/set_ad_dns_scheduled_task.ps1.erb +6 -0
- data/cookbooks/mu-tools/templates/windows/sshd_config.erb +136 -0
- data/cookbooks/mu-utility/CHANGELOG.md +12 -0
- data/cookbooks/mu-utility/LICENSE +37 -0
- data/cookbooks/mu-utility/README.md +6 -0
- data/cookbooks/mu-utility/attributes/default.rb +1 -0
- data/cookbooks/mu-utility/libraries/matchers.rb +21 -0
- data/cookbooks/mu-utility/metadata.rb +16 -0
- data/cookbooks/mu-utility/recipes/apt.rb +23 -0
- data/cookbooks/mu-utility/recipes/cleanup_image_helper.rb +118 -0
- data/cookbooks/mu-utility/recipes/iptables.rb +26 -0
- data/cookbooks/mu-utility/recipes/luks.rb +18 -0
- data/cookbooks/mu-utility/recipes/nat.rb +104 -0
- data/cookbooks/mu-utility/recipes/php.rb +33 -0
- data/cookbooks/mu-utility/recipes/rdp_gateway.rb +83 -0
- data/cookbooks/mu-utility/recipes/remi.rb +44 -0
- data/cookbooks/mu-utility/recipes/vim.rb +26 -0
- data/cookbooks/mu-utility/recipes/windows_basics.rb +37 -0
- data/cookbooks/mu-utility/recipes/zip.rb +26 -0
- data/cookbooks/mu-utility/templates/default/BundleConfig.xml.erb +34 -0
- data/cookbooks/mu-utility/templates/default/config.xml.erb +60 -0
- data/cookbooks/nagios/Berksfile +8 -0
- data/cookbooks/nagios/CHANGELOG.md +589 -0
- data/cookbooks/nagios/CONTRIBUTING.md +11 -0
- data/cookbooks/nagios/LICENSE +37 -0
- data/cookbooks/nagios/README.md +328 -0
- data/cookbooks/nagios/TESTING.md +2 -0
- data/cookbooks/nagios/attributes/config.rb +171 -0
- data/cookbooks/nagios/attributes/default.rb +228 -0
- data/cookbooks/nagios/chefignore +102 -0
- data/cookbooks/nagios/definitions/command.rb +33 -0
- data/cookbooks/nagios/definitions/contact.rb +33 -0
- data/cookbooks/nagios/definitions/contactgroup.rb +33 -0
- data/cookbooks/nagios/definitions/host.rb +33 -0
- data/cookbooks/nagios/definitions/hostdependency.rb +33 -0
- data/cookbooks/nagios/definitions/hostescalation.rb +34 -0
- data/cookbooks/nagios/definitions/hostgroup.rb +33 -0
- data/cookbooks/nagios/definitions/nagios_conf.rb +38 -0
- data/cookbooks/nagios/definitions/resource.rb +33 -0
- data/cookbooks/nagios/definitions/service.rb +33 -0
- data/cookbooks/nagios/definitions/servicedependency.rb +33 -0
- data/cookbooks/nagios/definitions/serviceescalation.rb +34 -0
- data/cookbooks/nagios/definitions/servicegroup.rb +33 -0
- data/cookbooks/nagios/definitions/timeperiod.rb +33 -0
- data/cookbooks/nagios/libraries/base.rb +314 -0
- data/cookbooks/nagios/libraries/command.rb +91 -0
- data/cookbooks/nagios/libraries/contact.rb +230 -0
- data/cookbooks/nagios/libraries/contactgroup.rb +112 -0
- data/cookbooks/nagios/libraries/custom_option.rb +36 -0
- data/cookbooks/nagios/libraries/data_bag_helper.rb +23 -0
- data/cookbooks/nagios/libraries/default.rb +90 -0
- data/cookbooks/nagios/libraries/host.rb +412 -0
- data/cookbooks/nagios/libraries/hostdependency.rb +181 -0
- data/cookbooks/nagios/libraries/hostescalation.rb +173 -0
- data/cookbooks/nagios/libraries/hostgroup.rb +119 -0
- data/cookbooks/nagios/libraries/nagios.rb +282 -0
- data/cookbooks/nagios/libraries/resource.rb +59 -0
- data/cookbooks/nagios/libraries/service.rb +455 -0
- data/cookbooks/nagios/libraries/servicedependency.rb +215 -0
- data/cookbooks/nagios/libraries/serviceescalation.rb +195 -0
- data/cookbooks/nagios/libraries/servicegroup.rb +144 -0
- data/cookbooks/nagios/libraries/timeperiod.rb +160 -0
- data/cookbooks/nagios/libraries/users_helper.rb +54 -0
- data/cookbooks/nagios/metadata.rb +25 -0
- data/cookbooks/nagios/recipes/_load_databag_config.rb +153 -0
- data/cookbooks/nagios/recipes/_load_default_config.rb +241 -0
- data/cookbooks/nagios/recipes/apache.rb +48 -0
- data/cookbooks/nagios/recipes/default.rb +204 -0
- data/cookbooks/nagios/recipes/nginx.rb +82 -0
- data/cookbooks/nagios/recipes/pagerduty.rb +143 -0
- data/cookbooks/nagios/recipes/server_package.rb +40 -0
- data/cookbooks/nagios/recipes/server_source.rb +164 -0
- data/cookbooks/nagios/templates/default/apache2.conf.erb +96 -0
- data/cookbooks/nagios/templates/default/cgi.cfg.erb +266 -0
- data/cookbooks/nagios/templates/default/commands.cfg.erb +13 -0
- data/cookbooks/nagios/templates/default/contacts.cfg.erb +37 -0
- data/cookbooks/nagios/templates/default/hostgroups.cfg.erb +25 -0
- data/cookbooks/nagios/templates/default/hosts.cfg.erb +15 -0
- data/cookbooks/nagios/templates/default/htpasswd.users.erb +6 -0
- data/cookbooks/nagios/templates/default/nagios.cfg.erb +22 -0
- data/cookbooks/nagios/templates/default/nginx.conf.erb +62 -0
- data/cookbooks/nagios/templates/default/pagerduty.cgi.erb +185 -0
- data/cookbooks/nagios/templates/default/resource.cfg.erb +27 -0
- data/cookbooks/nagios/templates/default/servicedependencies.cfg.erb +15 -0
- data/cookbooks/nagios/templates/default/servicegroups.cfg.erb +14 -0
- data/cookbooks/nagios/templates/default/services.cfg.erb +14 -0
- data/cookbooks/nagios/templates/default/templates.cfg.erb +31 -0
- data/cookbooks/nagios/templates/default/timeperiods.cfg.erb +13 -0
- data/cookbooks/s3fs/CHANGELOG.md +13 -0
- data/cookbooks/s3fs/LICENSE +37 -0
- data/cookbooks/s3fs/README.md +6 -0
- data/cookbooks/s3fs/attributes/default.rb +15 -0
- data/cookbooks/s3fs/files/default/fuse-2.9.3.zip +0 -0
- data/cookbooks/s3fs/metadata.rb +16 -0
- data/cookbooks/s3fs/recipes/default.rb +91 -0
- data/data_bags/demo/app.json +7 -0
- data/data_bags/nagios_services/chef.json +6 -0
- data/data_bags/nagios_services/linux_diskspace.json +5 -0
- data/data_bags/nagios_services/momma_cat.json +6 -0
- data/data_bags/nagios_services/mu-master-memory.json +5 -0
- data/data_bags/nagios_services/nagios_ui.json +6 -0
- data/data_bags/nagios_services/node_ssh.json +6 -0
- data/data_bags/nagios_services/ssh.json +6 -0
- data/demo/lambda_test.yaml +29 -0
- data/environments/DEV.json +8 -0
- data/environments/PROD.json +8 -0
- data/environments/dev.json +8 -0
- data/environments/development.json +8 -0
- data/environments/prod.json +8 -0
- data/extras/README.md +1 -0
- data/extras/admin-role-binding.yaml +16 -0
- data/extras/admin-user.yaml +6 -0
- data/extras/aws-auth-cm.yaml.erb +12 -0
- data/extras/clean-stock-amis +48 -0
- data/extras/git-fix-permissions-hook +12 -0
- data/extras/gitlab-eks-helper.sh.erb +20 -0
- data/extras/image-generators/README.md +2 -0
- data/extras/image-generators/aws/centos6.yaml +18 -0
- data/extras/image-generators/aws/centos7-govcloud.yaml +24 -0
- data/extras/image-generators/aws/centos7.yaml +17 -0
- data/extras/image-generators/aws/rhel7.yaml +17 -0
- data/extras/image-generators/aws/win2k12.yaml +16 -0
- data/extras/image-generators/aws/win2k16.yaml +16 -0
- data/extras/image-generators/aws/windows.yaml +18 -0
- data/extras/image-generators/gcp/centos6.yaml +17 -0
- data/extras/lambda_waf_domain_blacklist.py +103 -0
- data/extras/platform_berksfile_base +50 -0
- data/extras/ruby_rpm/build.sh +17 -0
- data/extras/ruby_rpm/muby.spec +44 -0
- data/extras/vault_tools/README.md +6 -0
- data/extras/vault_tools/export_vaults.sh +3 -0
- data/extras/vault_tools/recreate_vaults.sh +5 -0
- data/extras/vault_tools/test_vaults.sh +5 -0
- data/install/README.md +8 -0
- data/install/cfn_create_mu_master.json +1034 -0
- data/install/chef-server.rb.erb +19 -0
- data/install/deprecated-bash-library.sh +1891 -0
- data/install/images/Usage.png +0 -0
- data/install/installer +71 -0
- data/install/jenkinskeys.rb +8 -0
- data/install/user-dot-murc.erb +14 -0
- data/modules/html.erb +19 -0
- data/modules/mommacat.ru +426 -0
- data/modules/mu/cleanup.rb +339 -0
- data/modules/mu/cloud.rb +1446 -0
- data/modules/mu/clouds/README.md +201 -0
- data/modules/mu/clouds/aws/alarm.rb +319 -0
- data/modules/mu/clouds/aws/cache_cluster.rb +1010 -0
- data/modules/mu/clouds/aws/collection.rb +373 -0
- data/modules/mu/clouds/aws/container_cluster.rb +667 -0
- data/modules/mu/clouds/aws/database.rb +1836 -0
- data/modules/mu/clouds/aws/dnszone.rb +911 -0
- data/modules/mu/clouds/aws/firewall_rule.rb +641 -0
- data/modules/mu/clouds/aws/folder.rb +92 -0
- data/modules/mu/clouds/aws/function.rb +349 -0
- data/modules/mu/clouds/aws/group.rb +251 -0
- data/modules/mu/clouds/aws/loadbalancer.rb +888 -0
- data/modules/mu/clouds/aws/log.rb +363 -0
- data/modules/mu/clouds/aws/msg_queue.rb +480 -0
- data/modules/mu/clouds/aws/notification.rb +139 -0
- data/modules/mu/clouds/aws/role.rb +656 -0
- data/modules/mu/clouds/aws/search_domain.rb +646 -0
- data/modules/mu/clouds/aws/server.rb +2294 -0
- data/modules/mu/clouds/aws/server_pool.rb +1388 -0
- data/modules/mu/clouds/aws/storage_pool.rb +495 -0
- data/modules/mu/clouds/aws/user.rb +382 -0
- data/modules/mu/clouds/aws/userdata/README.md +4 -0
- data/modules/mu/clouds/aws/userdata/linux.erb +179 -0
- data/modules/mu/clouds/aws/userdata/windows.erb +278 -0
- data/modules/mu/clouds/aws/vpc.rb +1943 -0
- data/modules/mu/clouds/aws.rb +1009 -0
- data/modules/mu/clouds/cloudformation/alarm.rb +146 -0
- data/modules/mu/clouds/cloudformation/cache_cluster.rb +167 -0
- data/modules/mu/clouds/cloudformation/collection.rb +117 -0
- data/modules/mu/clouds/cloudformation/database.rb +278 -0
- data/modules/mu/clouds/cloudformation/dnszone.rb +274 -0
- data/modules/mu/clouds/cloudformation/firewall_rule.rb +308 -0
- data/modules/mu/clouds/cloudformation/loadbalancer.rb +193 -0
- data/modules/mu/clouds/cloudformation/log.rb +170 -0
- data/modules/mu/clouds/cloudformation/server.rb +370 -0
- data/modules/mu/clouds/cloudformation/server_pool.rb +279 -0
- data/modules/mu/clouds/cloudformation/vpc.rb +322 -0
- data/modules/mu/clouds/cloudformation.rb +733 -0
- data/modules/mu/clouds/docker.rb +30 -0
- data/modules/mu/clouds/google/container_cluster.rb +290 -0
- data/modules/mu/clouds/google/database.rb +152 -0
- data/modules/mu/clouds/google/firewall_rule.rb +267 -0
- data/modules/mu/clouds/google/group.rb +164 -0
- data/modules/mu/clouds/google/loadbalancer.rb +479 -0
- data/modules/mu/clouds/google/server.rb +1510 -0
- data/modules/mu/clouds/google/server_pool.rb +274 -0
- data/modules/mu/clouds/google/user.rb +266 -0
- data/modules/mu/clouds/google/userdata/README.md +4 -0
- data/modules/mu/clouds/google/userdata/linux.erb +137 -0
- data/modules/mu/clouds/google/userdata/windows.erb +275 -0
- data/modules/mu/clouds/google/vpc.rb +890 -0
- data/modules/mu/clouds/google.rb +811 -0
- data/modules/mu/config/README.md +11 -0
- data/modules/mu/config/alarm.rb +271 -0
- data/modules/mu/config/cache_cluster.rb +172 -0
- data/modules/mu/config/collection.rb +87 -0
- data/modules/mu/config/container_cluster.rb +103 -0
- data/modules/mu/config/container_cluster.yml +36 -0
- data/modules/mu/config/database.rb +458 -0
- data/modules/mu/config/database.yml +26 -0
- data/modules/mu/config/dnszone.rb +327 -0
- data/modules/mu/config/firewall_rule.rb +118 -0
- data/modules/mu/config/folder.rb +70 -0
- data/modules/mu/config/function.rb +140 -0
- data/modules/mu/config/group.rb +64 -0
- data/modules/mu/config/loadbalancer.rb +482 -0
- data/modules/mu/config/log.rb +47 -0
- data/modules/mu/config/log.yml +6 -0
- data/modules/mu/config/msg_queue.rb +47 -0
- data/modules/mu/config/msg_queue.yml +9 -0
- data/modules/mu/config/notification.rb +44 -0
- data/modules/mu/config/project.rb +71 -0
- data/modules/mu/config/role.rb +102 -0
- data/modules/mu/config/search_domain.rb +61 -0
- data/modules/mu/config/search_domain.yml +25 -0
- data/modules/mu/config/server.rb +587 -0
- data/modules/mu/config/server.yml +8 -0
- data/modules/mu/config/server_pool.rb +216 -0
- data/modules/mu/config/server_pool.yml +71 -0
- data/modules/mu/config/storage_pool.rb +145 -0
- data/modules/mu/config/user.rb +78 -0
- data/modules/mu/config/vpc.rb +743 -0
- data/modules/mu/config/vpc.yml +6 -0
- data/modules/mu/config.rb +2000 -0
- data/modules/mu/defaults/README.md +2 -0
- data/modules/mu/defaults/amazon_images.yaml +121 -0
- data/modules/mu/defaults/google_images.yaml +16 -0
- data/modules/mu/deploy.rb +686 -0
- data/modules/mu/groomer.rb +123 -0
- data/modules/mu/groomers/README.md +58 -0
- data/modules/mu/groomers/chef.rb +1024 -0
- data/modules/mu/kittens.rb +11319 -0
- data/modules/mu/logger.rb +208 -0
- data/modules/mu/master/README.md +27 -0
- data/modules/mu/master/chef.rb +471 -0
- data/modules/mu/master/ldap.rb +1005 -0
- data/modules/mu/master.rb +415 -0
- data/modules/mu/mommacat.rb +2703 -0
- data/modules/mu-load-config.rb +1 -0
- data/modules/mu.rb +724 -0
- data/modules/scratchpad.erb +1 -0
- data/modules/tests/super_complex_bok.yml +41 -0
- data/modules/tests/super_simple_bok.yml +40 -0
- data/mu.gemspec +62 -0
- data/roles/demo-dbservice-configure.json +19 -0
- data/roles/demo-portal-configure.json +19 -0
- data/roles/mu-master-jenkins.json +24 -0
- data/roles/mu-master-nagios-only.json +13 -0
- data/roles/mu-master.json +12 -0
- data/roles/mu-node.json +19 -0
- data/roles/mu-splunk-server.json +13 -0
- data/roles/mu-splunk.json +13 -0
- data/test/clean_up.py +25 -0
- data/test/demo-test-profile/README.md +3 -0
- data/test/demo-test-profile/controls/flask.rb +84 -0
- data/test/demo-test-profile/inspec.lock +7 -0
- data/test/demo-test-profile/inspec.yml +11 -0
- data/test/etco-test-profile/README.md +3 -0
- data/test/etco-test-profile/controls/all-in-one.rb +182 -0
- data/test/etco-test-profile/inspec.lock +7 -0
- data/test/etco-test-profile/inspec.yml +11 -0
- data/test/exec_inspec.py +246 -0
- data/test/exec_mu_install.py +241 -0
- data/test/exec_retry.py +44 -0
- data/test/mu-master-test/README.md +3 -0
- data/test/mu-master-test/controls/all_in_one.rb +557 -0
- data/test/mu-master-test/inspec.lock +3 -0
- data/test/mu-master-test/inspec.yml +11 -0
- data/test/mu-tools-test/README.md +3 -0
- data/test/mu-tools-test/controls/base.rb +265 -0
- data/test/mu-tools-test/inspec.lock +3 -0
- data/test/mu-tools-test/inspec.yml +8 -0
- data/test/simple-server-php-test/README.md +3 -0
- data/test/simple-server-php-test/controls/apachephp.rb +25 -0
- data/test/simple-server-php-test/controls/example.rb +19 -0
- data/test/simple-server-php-test/inspec.lock +7 -0
- data/test/simple-server-php-test/inspec.yml +12 -0
- data/test/simple-server-rails-test/README.md +3 -0
- data/test/simple-server-rails-test/controls/rails.rb +188 -0
- data/test/simple-server-rails-test/inspec.lock +7 -0
- data/test/simple-server-rails-test/inspec.yml +11 -0
- data/test/simple-windows-test/README.md +3 -0
- data/test/simple-windows-test/controls/windows.rb +20 -0
- data/test/simple-windows-test/inspec.lock +7 -0
- data/test/simple-windows-test/inspec.yml +11 -0
- data/test/smoke_test.rb +75 -0
- data/test/wordpress-test/README.md +3 -0
- data/test/wordpress-test/controls/wordpress.rb +97 -0
- data/test/wordpress-test/inspec.lock +7 -0
- data/test/wordpress-test/inspec.yml +11 -0
- metadata +979 -0
|
@@ -0,0 +1,1891 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# This script installs and configures (or reconfigures) an Mu Master,
|
|
4
|
+
# setting up the Mu tools, Chef, and assorted support libraries and utilities.
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
# clean containing environment of nonsense
|
|
8
|
+
unset GEM_HOME
|
|
9
|
+
unset GEM_PATH
|
|
10
|
+
|
|
11
|
+
DIST_VERSION=`rpm -qa \*-release\* | grep -Ei "redhat|centos" | cut -d"-" -f3`
|
|
12
|
+
IS_AMAZON=0
|
|
13
|
+
if [ "$DIST_VERSION" == "" ];then # funny package name in Amazon Linux
|
|
14
|
+
# DIST_VERSION=`rpm -qa \*-release\* | cut -d"-" -f3` # XXX always 6 for now
|
|
15
|
+
DIST_VERSION=6
|
|
16
|
+
IS_AMAZON=1
|
|
17
|
+
elif [ "$DIST_VERSION" == "server" ];then # funny package name in RHEL6
|
|
18
|
+
DIST_VERSION="6"
|
|
19
|
+
fi
|
|
20
|
+
EPEL_RPM="http://mirror.metrocast.net/fedora/epel/epel-release-latest-$DIST_VERSION.noarch.rpm"
|
|
21
|
+
|
|
22
|
+
CHEF_CLIENT_VERSION="12.17.44-1"
|
|
23
|
+
CHEF_SERVER_VERSION="12.11.1-1"
|
|
24
|
+
|
|
25
|
+
if [ "$DIST_VERSION" == "7" ];then
|
|
26
|
+
# mariadb replaces mysql, qt and qt-x11 are required by gecode which is required by the dep_selector gem.
|
|
27
|
+
PACKAGES="git curl vim-enhanced zip unzip java-1.8.0-openjdk gcc gcc-c++ make libxml2-devel libxslt-devel cryptsetup-luks python-pip lsof mlocate strace nmap openssl-devel readline-devel python-devel ImageMagick-devel diffutils patch bind-utils httpd-tools gecode-devel mailx postgresql-devel openssl libyaml graphviz graphviz-devel mariadb mariadb-devel qt qt-x11 iptables-services jq"
|
|
28
|
+
DEL_PACKAGES="nagios firewalld"
|
|
29
|
+
OPSCODE_CHEF_PKG="chef-server-core-$CHEF_SERVER_VERSION.el7.x86_64"
|
|
30
|
+
OPSCODE_CHEF_DL="https://packages.chef.io/stable/el/7/${OPSCODE_CHEF_PKG}.rpm"
|
|
31
|
+
CHEF_CLIENT_PKG="chef-$CHEF_CLIENT_VERSION.el7.x86_64"
|
|
32
|
+
RUBY_RPM="https://s3.amazonaws.com/cloudamatic/ruby23-2.3.1-1.el7.centos.x86_64.rpm"
|
|
33
|
+
RUBY_INSTALL_DIR="/opt/rubies/ruby-2.3.1"
|
|
34
|
+
RUBY_VERSION="ruby23-2.3.1"
|
|
35
|
+
GECODE_RPMS="https://s3.amazonaws.com/cap-public/gecode-3.7.3-2.el7.centos.x86_64.rpm https://s3.amazonaws.com/cap-public/gecode-devel-3.7.3-2.el7.centos.x86_64.rpm"
|
|
36
|
+
else
|
|
37
|
+
PACKAGES="git curl vim-enhanced zip unzip java-1.5.0-gcj java-1.8.0-openjdk mysql-server gcc gcc-c++ make libxml2-devel libxslt-devel cryptsetup-luks python-pip lsof mlocate strace nmap openssl-devel readline-devel python-devel diffutils patch bind-utils httpd-tools mailx mysql-devel postgresql-devel openssl libyaml graphviz autoconf ImageMagick-devel graphviz-devel jq"
|
|
38
|
+
if [ "$IS_AMAZON" != "1" ];then
|
|
39
|
+
PACKAGES="${PACKAGES} gecode-devel"
|
|
40
|
+
# else
|
|
41
|
+
# PACKAGES="${PACKAGES} "
|
|
42
|
+
fi
|
|
43
|
+
OPSCODE_CHEF_PKG="chef-server-core-$CHEF_SERVER_VERSION.el6.x86_64"
|
|
44
|
+
OPSCODE_CHEF_DL="https://packages.chef.io/stable/el/6/${OPSCODE_CHEF_PKG}.rpm"
|
|
45
|
+
CHEF_CLIENT_PKG="chef-$CHEF_CLIENT_VERSION.el6.x86_64"
|
|
46
|
+
RUBY_RPM="https://s3.amazonaws.com/cloudamatic/ruby23-2.3.1-1.el6.x86_64.rpm"
|
|
47
|
+
RUBY_INSTALL_DIR="/opt/rubies/ruby-2.3.1"
|
|
48
|
+
RUBY_VERSION="ruby23-2.3.1"
|
|
49
|
+
DEL_PACKAGES="nagios"
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
if ! curl --fail http://169.254.169.254/latest/meta-data/instance-id > /dev/null 2>&1;then
|
|
53
|
+
IN_AWS=0
|
|
54
|
+
else
|
|
55
|
+
GET_METADATA="curl --fail -s -S http://169.254.169.254/latest"
|
|
56
|
+
IN_AWS=1
|
|
57
|
+
fi
|
|
58
|
+
if ! curl --fail http://metadata.google.internal/computeMetadata/v1/instance/name -H "Metadata-Flavor: Google" > /dev/null 2>&1;then
|
|
59
|
+
IN_GOOGLE=0
|
|
60
|
+
else
|
|
61
|
+
GET_METADATA="curl --fail -s -S http://metadata.google.internal/computeMetadata/v1"
|
|
62
|
+
IN_GOOGLE=1
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
RCFILE=".murc"
|
|
66
|
+
|
|
67
|
+
#tput will cause a noninteractive session to silently fail, else color things
|
|
68
|
+
if [ -t 0 ]; then
|
|
69
|
+
BOLD=`tput bold`
|
|
70
|
+
NORM=`tput sgr0`
|
|
71
|
+
BLACK=`tput setaf 0`
|
|
72
|
+
RED=`tput setaf 1`
|
|
73
|
+
GREEN=`tput setaf 2`
|
|
74
|
+
YELLOW=`tput setaf 3`
|
|
75
|
+
BLUE=`tput setaf 4`
|
|
76
|
+
PINK=`tput setaf 5`
|
|
77
|
+
CYAN=`tput setaf 6`
|
|
78
|
+
WHITE=`tput setaf 7`
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
export PATH="/bin:/usr/bin:/sbin:/usr/sbin"
|
|
82
|
+
|
|
83
|
+
# Non-root users can only customize certain configuration parameters
|
|
84
|
+
if [ "root" == "`whoami`" ];then
|
|
85
|
+
CONFIG_VARS="AWS_ACCESS AWS_SECRET MU_ADMIN_EMAIL MU_ADMIN_PW JENKINS_ADMIN_PW MU_INSTALLDIR MU_DATADIR ADDTL_CHEF_REPOS MU_REPO CHEF_PUBLIC_IP HOST_NAME EC2SECGROUP LOG_BUCKET_NAME ALLOW_INVADE_FOREIGN_VPCS MU_SSL_CERT MU_SSL_KEY MU_SSL_CHAIN"
|
|
86
|
+
RO_CONFIG_VARS="AWS_ACCOUNT_NUMBER EC2_REGION"
|
|
87
|
+
else
|
|
88
|
+
CONFIG_VARS="AWS_ACCESS AWS_SECRET MU_DATADIR ADDTL_CHEF_REPOS MU_REPO LOG_BUCKET_NAME"
|
|
89
|
+
RO_CONFIG_VARS="AWS_ACCOUNT_NUMBER EC2_REGION CHEF_PUBLIC_IP HOST_NAME EC2SECGROUP MU_INSTALLDIR"
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
usage()
|
|
93
|
+
{
|
|
94
|
+
echo "Create or reconfigure your Chef master."
|
|
95
|
+
echo "Usage: $0 [-d] [-c /path/to/murc] [-b branch]"
|
|
96
|
+
echo " -d: Use default values and run non-interactively."
|
|
97
|
+
echo " -b: Choose a branch (default: master)."
|
|
98
|
+
echo " -c: Use an alternate .murc file."
|
|
99
|
+
echo " -k: Run curl with -k to skip SSL certificate checks."
|
|
100
|
+
exit 1
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
_me="`basename $0`"
|
|
104
|
+
#if [ "$_me" == "mu-configure" ];then
|
|
105
|
+
# chef_artifacts_uploaded=1
|
|
106
|
+
# if [ -d "$MU_LIBDIR/.git" ]; then
|
|
107
|
+
# cd $MU_LIBDIR
|
|
108
|
+
# MUBRANCH="`git branch 2>/dev/null | egrep '^\*' |cut -d' ' -f2`"
|
|
109
|
+
# fi
|
|
110
|
+
#fi
|
|
111
|
+
|
|
112
|
+
if [ "$_me" == "mu-self-update" ];then
|
|
113
|
+
library=1
|
|
114
|
+
fi
|
|
115
|
+
if [ "$_me" == "mu-upload-chef-artifacts" ];then
|
|
116
|
+
library=1
|
|
117
|
+
fi
|
|
118
|
+
if [ "$_me" == "mu-user-manage" ];then
|
|
119
|
+
library=1
|
|
120
|
+
fi
|
|
121
|
+
curl_dash_k=1
|
|
122
|
+
chef_self_test=0
|
|
123
|
+
if [ "$library" != "1" ];then
|
|
124
|
+
while getopts "c:tdhkb:" opt; do
|
|
125
|
+
case $opt in
|
|
126
|
+
c)
|
|
127
|
+
MURC=$OPTARG
|
|
128
|
+
;;
|
|
129
|
+
d)
|
|
130
|
+
use_defaults=1
|
|
131
|
+
;;
|
|
132
|
+
b)
|
|
133
|
+
MUBRANCH=$OPTARG
|
|
134
|
+
;;
|
|
135
|
+
k)
|
|
136
|
+
curl_dash_k=1
|
|
137
|
+
;;
|
|
138
|
+
h)
|
|
139
|
+
usage
|
|
140
|
+
;;
|
|
141
|
+
\?)
|
|
142
|
+
usage
|
|
143
|
+
;;
|
|
144
|
+
esac
|
|
145
|
+
done
|
|
146
|
+
else
|
|
147
|
+
set +e
|
|
148
|
+
set +x
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
umask 0077
|
|
152
|
+
|
|
153
|
+
# Populate key environment variables. Default them to whatever's set in the
|
|
154
|
+
# environment we've inherited, and failing that, see if we can extract some of
|
|
155
|
+
# them from this instance's EC2 metadata.
|
|
156
|
+
USER=`whoami`
|
|
157
|
+
if [ "$MU_INSTALLDIR" == "" ];then
|
|
158
|
+
MU_INSTALLDIR="/opt/mu"
|
|
159
|
+
fi
|
|
160
|
+
if [ "$MU_SSL_CERT" == "" ];then
|
|
161
|
+
MU_SSL_CERT="/opt/mu/var/ssl/mommacat.crt"
|
|
162
|
+
fi
|
|
163
|
+
if [ "$MU_SSL_KEY" == "" ];then
|
|
164
|
+
MU_SSL_KEY="/opt/mu/var/ssl/mommacat.key"
|
|
165
|
+
fi
|
|
166
|
+
if [ "$MU_SSL_CHAIN" == "" ];then
|
|
167
|
+
MU_SSL_CHAIN="/opt/mu/var/ssl/Mu_CA.pem"
|
|
168
|
+
fi
|
|
169
|
+
HOMEDIR="`getent passwd \"$USER\" |cut -d: -f6`"
|
|
170
|
+
MU_CHEF_CACHE="$HOMEDIR/.chef"
|
|
171
|
+
if [ -z $MU_DATADIR ];then
|
|
172
|
+
if [ "$USER" != "root" ];then
|
|
173
|
+
MU_DATADIR="$HOMEDIR/.mu"
|
|
174
|
+
else
|
|
175
|
+
MU_DATADIR="$MU_INSTALLDIR/var"
|
|
176
|
+
fi
|
|
177
|
+
fi
|
|
178
|
+
if [ "$MU_LIBDIR" == "" ];then
|
|
179
|
+
MU_LIBDIR="$MU_INSTALLDIR/lib"
|
|
180
|
+
fi
|
|
181
|
+
if [ "$MURC" == "" ];then
|
|
182
|
+
if [ "$USER" != "root" ];then
|
|
183
|
+
MURC="$HOMEDIR/$RCFILE"
|
|
184
|
+
else
|
|
185
|
+
MURC="$MU_INSTALLDIR/etc/mu.rc"
|
|
186
|
+
test -f "$MU_INSTALLDIR/etc/mu.rc" || ( mkdir -p $MU_INSTALLDIR/etc && touch "$MU_INSTALLDIR/etc/mu.rc" )
|
|
187
|
+
chmod 755 $MU_INSTALLDIR/etc
|
|
188
|
+
fi
|
|
189
|
+
fi
|
|
190
|
+
|
|
191
|
+
# Source the global .murc file, then overlay the local one if it exists
|
|
192
|
+
test -f "$MU_INSTALLDIR/etc/mu.rc" && source "$MU_INSTALLDIR/etc/mu.rc"
|
|
193
|
+
if [ -f "$MURC" -a "$MURC" != "$MU_INSTALLDIR/etc/mu.rc" ] ;then
|
|
194
|
+
source $MURC
|
|
195
|
+
fi
|
|
196
|
+
|
|
197
|
+
MU_REPO='cloudamatic/mu.git'
|
|
198
|
+
if [ "$MUBRANCH" == "" ];then
|
|
199
|
+
if [ -d "$MU_LIBDIR/.git" ]; then
|
|
200
|
+
cd $MU_LIBDIR
|
|
201
|
+
MUBRANCH="`git branch 2>/dev/null | grep '^\*' | awk '{print $2}'`"
|
|
202
|
+
fi
|
|
203
|
+
if [ "$MUBRANCH" == "" ];then
|
|
204
|
+
MUBRANCH="master"
|
|
205
|
+
fi
|
|
206
|
+
fi
|
|
207
|
+
MU_REPO_NAME="`echo $MU_REPO | cut -d/ -f2 | sed -e 's/\.git$//'`"
|
|
208
|
+
MY_PRIVATE_IP=""
|
|
209
|
+
if [ "$IN_AWS" == "1" ];then
|
|
210
|
+
if [ "$EC2_AVAILABILITY_ZONE" == "" ];then
|
|
211
|
+
EC2_AVAILABILITY_ZONE=`$GET_METADATA/meta-data/placement/availability-zone`
|
|
212
|
+
fi
|
|
213
|
+
if [ "$EC2_REGION" == "" ];then
|
|
214
|
+
EC2_REGION=`$GET_METADATA/dynamic/instance-identity/document|grep region|awk -F\" '{print $4}'`
|
|
215
|
+
fi
|
|
216
|
+
if [ "$AWS_ACCOUNT_NUMBER" == "" ];then
|
|
217
|
+
AWS_ACCOUNT_NUMBER=`$GET_METADATA/dynamic/instance-identity/document|grep accountId|awk -F\" '{print $4}'`
|
|
218
|
+
fi
|
|
219
|
+
ip_pattern='^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'
|
|
220
|
+
MY_INSTANCE_ID="`$GET_METADATA/meta-data/instance-id`"
|
|
221
|
+
MY_PRIVATE_IP="`$GET_METADATA/meta-data/local-ipv4 | egrep \"$ip_pattern\"`"
|
|
222
|
+
MY_PUBLIC_IP="`$GET_METADATA/meta-data/public-ipv4 2>&1 | egrep \"$ip_pattern\"`"
|
|
223
|
+
if [ "$MY_PRIVATE_IP" == "" ];then
|
|
224
|
+
echo "Couldn't determine my private IP with '$GET_METADATA/meta-data/local-ipv4'"
|
|
225
|
+
exit 1
|
|
226
|
+
fi
|
|
227
|
+
elif [ "$IN_GOOGLE" == "1" ];then
|
|
228
|
+
MY_INSTANCE_ID="`$GET_METADATA/instance/name -H 'Metadata-Flavor: Google'`"
|
|
229
|
+
MY_PRIVATE_IP="`$GET_METADATA/instance/network-interfaces/0/ip -H 'Metadata-Flavor: Google'`"
|
|
230
|
+
if [ "$MY_PRIVATE_IP" == "" ];then
|
|
231
|
+
echo "Couldn't determine my private IP with '$GET_METADATA/instance/network-interfaces/0/ip'"
|
|
232
|
+
exit 1
|
|
233
|
+
fi
|
|
234
|
+
# MY_PUBLIC_IP="`$GET_METADATA/meta-data/public-ipv4 | egrep \"$ip_pattern\"`"
|
|
235
|
+
fi
|
|
236
|
+
if [ "$CHEF_PUBLIC_IP" == "" -a "$MY_PUBLIC_IP" != "" ];then
|
|
237
|
+
CHEF_PUBLIC_IP=$MY_PUBLIC_IP
|
|
238
|
+
fi
|
|
239
|
+
if [ "$MY_PUBLIC_IP" == "" ];then
|
|
240
|
+
MY_PUBLIC_IP=$MY_PRIVATE_IP
|
|
241
|
+
fi
|
|
242
|
+
if [ "$HOST_NAME" == "" ];then
|
|
243
|
+
HOST_NAME="`hostname -s`"
|
|
244
|
+
fi
|
|
245
|
+
MY_VPC_ID=""
|
|
246
|
+
# Figure out if we have at least one interface in a VPC
|
|
247
|
+
if [ "$IN_AWS" == "1" ];then
|
|
248
|
+
if [ "$LOG_BUCKET_NAME" == "" ];then
|
|
249
|
+
LOG_BUCKET_NAME="mu-logs-${HOST_NAME}-${MY_INSTANCE_ID}"
|
|
250
|
+
fi
|
|
251
|
+
for mac in `$GET_METADATA/meta-data/network/interfaces/macs/`;do
|
|
252
|
+
vpc_id="`$GET_METADATA/meta-data/network/interfaces/macs/$mac/vpc-id | egrep '^vpc\-'`"
|
|
253
|
+
if [ "$vpc_id" != "" ];then
|
|
254
|
+
MY_VPC_ID=$vpc_id
|
|
255
|
+
break
|
|
256
|
+
fi
|
|
257
|
+
done
|
|
258
|
+
IAM_ROLE="`$GET_METADATA/meta-data/iam/security-credentials/ 2> /dev/null`"
|
|
259
|
+
fi
|
|
260
|
+
|
|
261
|
+
###############################################################################
|
|
262
|
+
fail_with_message()
|
|
263
|
+
{
|
|
264
|
+
if [ "$1" != "" ];then
|
|
265
|
+
echo ""
|
|
266
|
+
echo "${RED}*******************************************************************************${NORM}"
|
|
267
|
+
echo "${RED}*******************************************************************************${NORM}"
|
|
268
|
+
echo $1
|
|
269
|
+
test "$2" != "" && echo $2
|
|
270
|
+
echo "${RED}*******************************************************************************${NORM}"
|
|
271
|
+
echo "${RED}*******************************************************************************${NORM}"
|
|
272
|
+
echo ""
|
|
273
|
+
fi
|
|
274
|
+
exit 1
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
###############################################################################
|
|
278
|
+
warning_message()
|
|
279
|
+
{
|
|
280
|
+
if [ "$1" != "" ];then
|
|
281
|
+
echo ""
|
|
282
|
+
echo "${YELLOW}*******************************************************************************${NORM}"
|
|
283
|
+
echo $1
|
|
284
|
+
test "$2" != "" && echo $2
|
|
285
|
+
echo "${YELLOW}*******************************************************************************${NORM}"
|
|
286
|
+
echo ""
|
|
287
|
+
fi
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
###############################################################################
|
|
291
|
+
status_message()
|
|
292
|
+
{
|
|
293
|
+
if [ "$1" != "" ];then
|
|
294
|
+
echo ""
|
|
295
|
+
echo "${GREEN}*******************************************************************************${NORM}"
|
|
296
|
+
echo $1
|
|
297
|
+
test "$2" != "" && echo $2
|
|
298
|
+
echo "${GREEN}*******************************************************************************${NORM}"
|
|
299
|
+
echo ""
|
|
300
|
+
fi
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
###############################################################################
|
|
304
|
+
# Useful for accessing our parallel key/value structure.
|
|
305
|
+
# Accepts named key as argument
|
|
306
|
+
# Returns value of target env variable from array structures
|
|
307
|
+
# Uses stdout so do **not** echo or printf in this function
|
|
308
|
+
###############################################################################
|
|
309
|
+
|
|
310
|
+
return_targetvar_value()
|
|
311
|
+
|
|
312
|
+
{
|
|
313
|
+
for i in "${!var_name[@]}"; do
|
|
314
|
+
|
|
315
|
+
if [ ${var_name[$i]} = "$1" ]; then
|
|
316
|
+
printf '%s' ${var_val[$i]}
|
|
317
|
+
break
|
|
318
|
+
fi
|
|
319
|
+
done
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
###############################################################################
|
|
325
|
+
update_murc()
|
|
326
|
+
{
|
|
327
|
+
name="$1"
|
|
328
|
+
value="$2"
|
|
329
|
+
murc_path="$3"
|
|
330
|
+
if [ "$murc_path" == "" ];then
|
|
331
|
+
murc_path="$MURC"
|
|
332
|
+
fi
|
|
333
|
+
if [ "$name" == "" ];then
|
|
334
|
+
fail_with_message "update_murc called with missing variable name"
|
|
335
|
+
fi
|
|
336
|
+
test -f $murc_path && sed -i "/^export $name=.*/d" $murc_path
|
|
337
|
+
echo "export $name=\"$value\"" >> $murc_path
|
|
338
|
+
chmod 644 $murc_path
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
###############################################################################
|
|
342
|
+
set_path_env_vars()
|
|
343
|
+
{
|
|
344
|
+
MU_REPO_NAME="`echo $MU_REPO | cut -d/ -f2 | sed -e 's/\.git$//'`"
|
|
345
|
+
HOMEDIR="`getent passwd \"$USER\" |cut -d: -f6`"
|
|
346
|
+
MU_CHEF_CACHE="$HOMEDIR/.chef"
|
|
347
|
+
SSHDIR="$HOMEDIR/.ssh"
|
|
348
|
+
ENVFILE="$HOMEDIR/.bash_profile"
|
|
349
|
+
mkdir -p $MU_INSTALLDIR/etc $MU_INSTALLDIR/bin $MU_DATADIR/deployments
|
|
350
|
+
chmod 755 $MU_INSTALLDIR $MU_DATADIR
|
|
351
|
+
DEVOPS_TMP_DIR='/tmp/.mu.$$'
|
|
352
|
+
update_murc MU_INSTALLDIR $MU_INSTALLDIR
|
|
353
|
+
update_murc MU_DATADIR $MU_DATADIR
|
|
354
|
+
AWS_ACCESS_KEY_ID=$AWS_ACCESS
|
|
355
|
+
AWS_SECRET_ACCESS_KEY=$AWS_SECRET
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
pivotal_cfg_setup(){
|
|
359
|
+
port=$2
|
|
360
|
+
if [ "$port" == "" ];then
|
|
361
|
+
port=7443
|
|
362
|
+
fi
|
|
363
|
+
cat >> /etc/opscode/pivotal.rb.tmp.$$ << EOF
|
|
364
|
+
node_name "pivotal"
|
|
365
|
+
chef_server_url "https://${CHEF_PUBLIC_IP}:$port"
|
|
366
|
+
chef_server_root "https://${CHEF_PUBLIC_IP}:$port"
|
|
367
|
+
client_key "/etc/opscode/pivotal.pem"
|
|
368
|
+
ssl_verify_mode :verify_none
|
|
369
|
+
EOF
|
|
370
|
+
if [ ! -f /etc/opscode/pivotal.rb -o "`diff /etc/opscode/pivotal.rb /etc/opscode/pivotal.rb.tmp.$$`" != "" ];then
|
|
371
|
+
/bin/mv -f /etc/opscode/pivotal.rb.tmp.$$ /etc/opscode/pivotal.rb
|
|
372
|
+
fi
|
|
373
|
+
pivotal_pem="/opt/opscode/embedded/service/omnibus-ctl/spec/fixtures/pivotal.pem"
|
|
374
|
+
if [ -f /etc/opscode/pivotal.pem ];then
|
|
375
|
+
pivotal_pem="/etc/opscode/pivotal.pem"
|
|
376
|
+
fi
|
|
377
|
+
pivotal_cfg="-u pivotal -k $pivotal_pem"
|
|
378
|
+
knife ssl fetch $pivotal_cfg > /dev/null 2>&1
|
|
379
|
+
eval "$1=\"$pivotal_cfg\""
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
remove_chef_org()
|
|
383
|
+
{
|
|
384
|
+
org="$1"
|
|
385
|
+
|
|
386
|
+
pivotal_cfg_setup pivotal_cfg
|
|
387
|
+
# chef-server-ctl generates a spectcular amount of stupid noise
|
|
388
|
+
filter="(ffi-yajl|falling back to ffi)"
|
|
389
|
+
|
|
390
|
+
if ! /opt/opscode/bin/chef-server-ctl org-list $pivotal_cfg 2>&1 | egrep -v "$filter" | grep "^$org$" >/dev/null;then
|
|
391
|
+
warning_message "Chef org ${BOLD}$org${NORM} already removed"
|
|
392
|
+
else
|
|
393
|
+
status_message "Deleting Chef org ${BOLD}$org${NORM}"
|
|
394
|
+
/opt/opscode/bin/chef-server-ctl org-delete -y "$org" $pivotal_cfg 2>&1 | egrep -v "$filter"
|
|
395
|
+
fi
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
manage_chef_org()
|
|
399
|
+
{
|
|
400
|
+
org=$1
|
|
401
|
+
orgname=$2
|
|
402
|
+
add_user=$3
|
|
403
|
+
association_user=$4
|
|
404
|
+
|
|
405
|
+
if curl -k -so /dev/null https://${CHEF_PUBLIC_IP}:7443;then
|
|
406
|
+
pivotal_cfg_setup pivotal_cfg
|
|
407
|
+
else
|
|
408
|
+
pivotal_cfg_setup pivotal_cfg 443
|
|
409
|
+
fi
|
|
410
|
+
|
|
411
|
+
# chef-server-ctl generates a spectcular amount of stupid noise
|
|
412
|
+
filter="(ffi-yajl|falling back to ffi)"
|
|
413
|
+
|
|
414
|
+
if [ "$orgname" == "" ];then
|
|
415
|
+
orgname="$org"
|
|
416
|
+
fi
|
|
417
|
+
|
|
418
|
+
mkdir -p $MU_DATADIR/orgs/$org
|
|
419
|
+
|
|
420
|
+
assoc=""
|
|
421
|
+
if [ "$association_user" != "" ];then
|
|
422
|
+
assoc="-a $association_user"
|
|
423
|
+
fi
|
|
424
|
+
keypath="$MU_DATADIR/orgs/$org/$org.org.key"
|
|
425
|
+
if ! /opt/opscode/bin/chef-server-ctl org-list $pivotal_cfg 2>&1 | egrep -v "$filter" | grep "^$org$" >/dev/null;then
|
|
426
|
+
if [ "$association_user" != "" ];then
|
|
427
|
+
status_message "Creating Chef organization ${BOLD}$org${NORM} with admin user ${BOLD}$association_user${NORM}"
|
|
428
|
+
else
|
|
429
|
+
status_message "Creating Chef organization ${BOLD}$org${NORM}"
|
|
430
|
+
fi
|
|
431
|
+
attempts=0
|
|
432
|
+
|
|
433
|
+
while : ;do
|
|
434
|
+
/bin/rm -f $keypath
|
|
435
|
+
cmd="/opt/opscode/bin/chef-server-ctl org-create $org $orgname $assoc -f $keypath $pivotal_cfg"
|
|
436
|
+
$cmd 2>&1 | egrep -v "$filter"
|
|
437
|
+
test -f $keypath && grep 'BEGIN RSA PRIVATE KEY' $keypath > /dev/null && break
|
|
438
|
+
attempts=`expr $attempts + 1`
|
|
439
|
+
if [ $attempts -gt 5 ];then
|
|
440
|
+
output="`$cmd 2>&1 | egrep -v \"$filter\"`"
|
|
441
|
+
warning_message "Unable to set up Chef org ${BOLD}$org${NORM}" "$cmd: $output"
|
|
442
|
+
break
|
|
443
|
+
fi
|
|
444
|
+
done
|
|
445
|
+
if [ "$association_user" != "" ];then
|
|
446
|
+
if [ "$association_user" != "mu" ];then
|
|
447
|
+
user_home="`getent passwd \"$association_user\" |cut -d: -f6`"
|
|
448
|
+
else
|
|
449
|
+
user_home="`getent passwd \"root\" |cut -d: -f6`"
|
|
450
|
+
fi
|
|
451
|
+
mkdir -p "$user_home/.chef"
|
|
452
|
+
/bin/cp -f "$keypath" "$user_home/.chef/"
|
|
453
|
+
fi
|
|
454
|
+
fi
|
|
455
|
+
|
|
456
|
+
if [ "$add_user" != "" -a "$add_user" != "$association_user" ];then
|
|
457
|
+
status_message "Adding ${BOLD}$add_user${NORM} to Chef organization ${BOLD}$org${NORM}"
|
|
458
|
+
cmd="/opt/opscode/bin/chef-server-ctl org-user-add $org $add_user $pivotal_cfg"
|
|
459
|
+
$cmd 2>&1 | egrep -v "$filter"
|
|
460
|
+
if [ "$org" != "mu" ];then
|
|
461
|
+
if [ "$add_user" != "mu" ];then
|
|
462
|
+
user_home="`getent passwd \"$add_user\" |cut -d: -f6`"
|
|
463
|
+
else
|
|
464
|
+
user_home="`getent passwd \"root\" |cut -d: -f6`"
|
|
465
|
+
fi
|
|
466
|
+
mkdir -p "$user_home/.chef"
|
|
467
|
+
/bin/cp -f "$keypath" "$user_home/.chef/"
|
|
468
|
+
fi
|
|
469
|
+
fi
|
|
470
|
+
# warning_message "Failed to add ${BOLD}$user${NORM} to Chef org ${BOLD}$org${NORM}" "$cmd"
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
remove_chef_user_from_org()
|
|
474
|
+
{
|
|
475
|
+
user="$1"
|
|
476
|
+
org="$2"
|
|
477
|
+
|
|
478
|
+
pivotal_cfg_setup pivotal_cfg
|
|
479
|
+
# chef-server-ctl generates a spectcular amount of stupid noise
|
|
480
|
+
filter="(ffi-yajl|falling back to ffi)"
|
|
481
|
+
|
|
482
|
+
status_message "Removing ${BOLD}$user${NORM} from Chef org ${BOLD}$org${NORM}"
|
|
483
|
+
|
|
484
|
+
/opt/opscode/bin/chef-server-ctl org-user-remove "$org" "$user" -y $pivotal_cfg 2>&1 | egrep -v "$filter"
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
remove_chef_user()
|
|
488
|
+
{
|
|
489
|
+
user="$1"
|
|
490
|
+
|
|
491
|
+
pivotal_cfg_setup pivotal_cfg
|
|
492
|
+
# chef-server-ctl generates a spectcular amount of stupid noise
|
|
493
|
+
filter="(ffi-yajl|falling back to ffi)"
|
|
494
|
+
|
|
495
|
+
if ! /opt/opscode/bin/chef-server-ctl user-list $pivotal_cfg 2>&1 | egrep -v "$filter" | grep "^$user$" >/dev/null;then
|
|
496
|
+
warning_message "Chef user ${BOLD}$user${NORM} already removed"
|
|
497
|
+
else
|
|
498
|
+
remove_chef_org "$user"
|
|
499
|
+
for org in `/opt/opscode/bin/chef-server-ctl user-show $user --with-orgs $pivotal_cfg 2>&1 | egrep -v "$filter" | grep ^organizations: |cut -d: -f2`;do
|
|
500
|
+
remove_chef_user_from_org "$user" "$org"
|
|
501
|
+
done
|
|
502
|
+
status_message "Deleting Chef user ${BOLD}$user${NORM}"
|
|
503
|
+
/opt/opscode/bin/chef-server-ctl user-delete "$user" -y $pivotal_cfg 2>&1 | egrep -v "$filter"
|
|
504
|
+
fi
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
list_chef_users(){
|
|
508
|
+
# chef-server-ctl generates a spectcular amount of stupid noise
|
|
509
|
+
filter="(ffi-yajl|falling back to ffi)"
|
|
510
|
+
list="`/opt/opscode/bin/chef-server-ctl user-list 2>&1 | egrep -v \"$filter\" | egrep -v '^(pivotal)$' | tr -s '\n' ' '`"
|
|
511
|
+
eval "$1=\"$list\""
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
manage_chef_user()
|
|
516
|
+
{
|
|
517
|
+
user="$1"
|
|
518
|
+
pass="$2"
|
|
519
|
+
name="$3"
|
|
520
|
+
email="$4"
|
|
521
|
+
org="$5"
|
|
522
|
+
is_admin="$6"
|
|
523
|
+
is_normal="$7"
|
|
524
|
+
replace="$8"
|
|
525
|
+
|
|
526
|
+
if [ "$is_admin" == "1" -a "$is_normal" == "1" ];then
|
|
527
|
+
fail_with_message "Can't force-set a Chef user to both administrator and regular user"
|
|
528
|
+
fi
|
|
529
|
+
|
|
530
|
+
mkdir -p "$MU_DATADIR/users/$user"
|
|
531
|
+
/bin/chmod g+rsx "$MU_DATADIR/users"
|
|
532
|
+
/bin/chgrp mu-users "$MU_DATADIR/users"
|
|
533
|
+
|
|
534
|
+
if curl -k -so /dev/null https://${CHEF_PUBLIC_IP}:7443;then
|
|
535
|
+
pivotal_cfg_setup pivotal_cfg
|
|
536
|
+
else
|
|
537
|
+
pivotal_cfg_setup pivotal_cfg 443
|
|
538
|
+
fi
|
|
539
|
+
|
|
540
|
+
# chef-server-ctl generates a spectcular amount of stupid noise
|
|
541
|
+
filter="(ffi-yajl|falling back to ffi)"
|
|
542
|
+
|
|
543
|
+
if ! ( [ -f "$MU_DATADIR/users/$user/$user.user.key" ] && /opt/opscode/bin/chef-server-ctl user-list 2>&1 | egrep -v "$filter" | grep "^$user$" >/dev/null );then
|
|
544
|
+
ok=1
|
|
545
|
+
if [ "$name" == "" ];then
|
|
546
|
+
warning_message "Must supply a real name to create new Chef user ${BOLD}$user${NORM}"
|
|
547
|
+
ok=0
|
|
548
|
+
fi
|
|
549
|
+
if [ "$email" == "" ];then
|
|
550
|
+
warning_message "Must supply an email address to create new Chef user ${BOLD}$user${NORM}"
|
|
551
|
+
ok=0
|
|
552
|
+
fi
|
|
553
|
+
if [ "$pass" == "" ];then
|
|
554
|
+
warning_message "Must supply a password to create new Chef user ${BOLD}$user${NORM}"
|
|
555
|
+
ok=0
|
|
556
|
+
fi
|
|
557
|
+
if [ "$ok" != "1" ];then
|
|
558
|
+
return
|
|
559
|
+
fi
|
|
560
|
+
status_message "Creating Chef user ${BOLD}$user${NORM} - $name ($email)"
|
|
561
|
+
attempts=0
|
|
562
|
+
keypath="$MU_DATADIR/users/$user/$user.user.key"
|
|
563
|
+
if [ ! -f "$MU_DATADIR/users/$user/$user.user.key" -a "$replace" != "" ];then
|
|
564
|
+
/opt/opscode/bin/chef-server-ctl user-delete "$user" -y $pivotal_cfg 2>&1 | egrep -v "$filter"
|
|
565
|
+
fi
|
|
566
|
+
create_cmd="/opt/opscode/bin/chef-server-ctl user-create $user $name $email $pass $pivotal_cfg -f $keypath"
|
|
567
|
+
while : ;do
|
|
568
|
+
/bin/rm -f "$keypath"
|
|
569
|
+
# XXX Flinging passwords around CLI calls is terrible, need a better way
|
|
570
|
+
# to do this. Maybe we need local-brew directory services.
|
|
571
|
+
$create_cmd 2>&1 | egrep -v "$filter"
|
|
572
|
+
test -f "$keypath" && grep 'BEGIN RSA PRIVATE KEY' "$keypath" > /dev/null && break
|
|
573
|
+
attempts=`expr $attempts + 1`
|
|
574
|
+
if [ $attempts -gt 5 ];then
|
|
575
|
+
output="`$create_cmd 2>&1 | egrep -v \"$filter\"`"
|
|
576
|
+
warning_message "Unable to set up Chef ${BOLD}$user${NORM} user" "$create_cmd: $output"
|
|
577
|
+
break
|
|
578
|
+
fi
|
|
579
|
+
done
|
|
580
|
+
if [ "$user" != "mu" ];then
|
|
581
|
+
user_home="`getent passwd \"$user\" |cut -d: -f6`"
|
|
582
|
+
else
|
|
583
|
+
user_home="`getent passwd \"root\" |cut -d: -f6`"
|
|
584
|
+
fi
|
|
585
|
+
mkdir -p "$user_home/.chef"
|
|
586
|
+
/bin/cp -f "$keypath" "$user_home/.chef/"
|
|
587
|
+
|
|
588
|
+
manage_chef_org "$user" "$user" "" "$user"
|
|
589
|
+
set_knife_rb "organizations/$user" "$user" "https://${CHEF_PUBLIC_IP}:7443"
|
|
590
|
+
|
|
591
|
+
status_message "Configuring ${BOLD}$user_home/.chef/client.rb${NORM}"
|
|
592
|
+
cat /dev/null > "$user_home/.chef/client.rb"
|
|
593
|
+
cat >> "$user_home/.chef/client.rb" << EOF
|
|
594
|
+
#
|
|
595
|
+
# Client settings
|
|
596
|
+
#
|
|
597
|
+
log_level :info
|
|
598
|
+
log_location STDOUT
|
|
599
|
+
chef_server_url "https://${CHEF_PUBLIC_IP}:7443/organizations/$user"
|
|
600
|
+
validation_client_name '$user-validator'
|
|
601
|
+
EOF
|
|
602
|
+
if [ "$user" != "mu" ];then
|
|
603
|
+
chown -R "$user" "$user_home/.chef/"
|
|
604
|
+
runuser -l "$user" -c "cd $user_home && /opt/chef/bin/knife ssl fetch" > /root/knifesslfetch.out 2>&1
|
|
605
|
+
else
|
|
606
|
+
/opt/chef/bin/knife ssl fetch > /dev/null 2>&1
|
|
607
|
+
fi
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
if [ "$add_org" != "" ];then
|
|
611
|
+
manage_chef_org "$add_org" "$add_org" "$user" "mu"
|
|
612
|
+
fi
|
|
613
|
+
if [ "$is_admin" == "1" ];then
|
|
614
|
+
manage_chef_org "mu" "" "$user"
|
|
615
|
+
elif [ "$is_normal" == "1" ];then
|
|
616
|
+
remove_chef_user_from_org "$user" "mu"
|
|
617
|
+
fi
|
|
618
|
+
else
|
|
619
|
+
status_message "Updating Chef user ${BOLD}$user${NORM}"
|
|
620
|
+
if [ "$add_org" != "" ];then
|
|
621
|
+
manage_chef_org "$add_org" "$add_org" "$user" "mu"
|
|
622
|
+
fi
|
|
623
|
+
if [ "$is_admin" == "1" ];then
|
|
624
|
+
manage_chef_org "mu" "" "$user"
|
|
625
|
+
elif [ "$is_normal" == "1" ];then
|
|
626
|
+
remove_chef_user_from_org "$user" "mu"
|
|
627
|
+
fi
|
|
628
|
+
if [ "$password" != "" ];then
|
|
629
|
+
warning_message "You'll have to enter the new password again for Chef" "Also it will display it back to you in plain text. Yeah."
|
|
630
|
+
/opt/opscode/bin/chef-server-ctl password $user
|
|
631
|
+
fi
|
|
632
|
+
fi
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
###############################################################################
|
|
637
|
+
validate_setup_env_vars(){
|
|
638
|
+
n=1
|
|
639
|
+
validate_errs=0
|
|
640
|
+
while [ "${var_name[$n]}" != "" ];do
|
|
641
|
+
if [ "${var_name[$n]}" == "AWS_ACCESS" -o "${var_name[$n]}" == "AWS_SECRET" ]; then
|
|
642
|
+
if [ "$IAM_ROLE" == "" -a "${var_val[$n]}" == "" ];then
|
|
643
|
+
warning_message "No IAM instance profile assigned to this server. You must specify AWS credentials."
|
|
644
|
+
validate_errs=1
|
|
645
|
+
fi
|
|
646
|
+
elif [ "${var_name[$n]}" == "CHEF_PUBLIC_IP" ]; then
|
|
647
|
+
if [ "${var_val[$n]}" == "" ];then
|
|
648
|
+
warning_message "An IP accessible to client nodes must be specified"
|
|
649
|
+
validate_errs=1
|
|
650
|
+
fi
|
|
651
|
+
elif [ "${var_name[$n]}" == "MU_ADMIN_EMAIL" ]; then
|
|
652
|
+
if [ "${var_val[$n]}" == "" ];then
|
|
653
|
+
warning_message "You must specify an email contact for the 'mu' admin user."
|
|
654
|
+
validate_errs=1
|
|
655
|
+
elif ! ( echo ${var_val[$n]} | egrep -q '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$' ) ; then
|
|
656
|
+
warning_message "The 'mu' admin user email contact is badly formed!"
|
|
657
|
+
validate_errs=1
|
|
658
|
+
fi
|
|
659
|
+
|
|
660
|
+
elif [ "${var_name[$n]}" == "MU_ADMIN_PW" -a ! -f "$MU_CHEF_CACHE/mu.user.key" ]; then
|
|
661
|
+
if [ "${var_val[$n]}" == "" ];then
|
|
662
|
+
warning_message "You must specify a password for the 'mu' admin user."
|
|
663
|
+
validate_errs=1
|
|
664
|
+
fi
|
|
665
|
+
|
|
666
|
+
elif [ "${var_name[$n]}" == "LOG_BUCKET_NAME" ]; then
|
|
667
|
+
if [ "${var_val[$n]}" == "" ];then
|
|
668
|
+
warning_message "You must specify a dns-legal log bucket name ."
|
|
669
|
+
validate_errs=1
|
|
670
|
+
elif ! ( echo ${var_val[$n]} | egrep -q '^[a-z0-9.-]*$' ) ; then
|
|
671
|
+
warning_message "The log bucket name is badly formed!"
|
|
672
|
+
validate_errs=1
|
|
673
|
+
fi
|
|
674
|
+
|
|
675
|
+
elif [ "${var_name[$n]}" == "JENKINS_ADMIN_PW" ]; then
|
|
676
|
+
if [ "${var_val[$n]}" == "" ];then
|
|
677
|
+
warning_message "You must specify a password for the 'jenkins' admin user to enable the Jenkins front-end. Jenkins will not be enabled at this time. Rerun mu-configure and supply a password if you wish to enable it."
|
|
678
|
+
sleep 5
|
|
679
|
+
fi
|
|
680
|
+
fi
|
|
681
|
+
n=$[$n +1]
|
|
682
|
+
done
|
|
683
|
+
|
|
684
|
+
MU_ADMIN_EMAIL_VAL=$(return_targetvar_value "MU_ADMIN_EMAIL")
|
|
685
|
+
JENKINS_ADMIN_EMAIL_VAL=$(return_targetvar_value "MU_ADMIN_EMAIL")
|
|
686
|
+
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
###############################################################################
|
|
690
|
+
print_setup_env_vars(){
|
|
691
|
+
echo "${CYAN}System-wide settings${NORM}:"
|
|
692
|
+
for ro in $RO_CONFIG_VARS;do
|
|
693
|
+
echo " ${BOLD}$ro${NORM}: ${CYAN}${!ro}${NORM}"
|
|
694
|
+
done
|
|
695
|
+
echo "${GREEN}Configurable settings to write to ${BOLD}$MURC${NORM}:"
|
|
696
|
+
n=1
|
|
697
|
+
while [ "${var_name[$n]}" != "" ];do
|
|
698
|
+
if [ "${var_name[$n]}" == "CHEF_PUBLIC_IP" ]; then
|
|
699
|
+
if [ "$MY_VPC_ID" != "" ];then
|
|
700
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (if in private subnet, set to bastion public IP): ${GREEN}${var_val[$n]}${NORM}"
|
|
701
|
+
else
|
|
702
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (OPTIONAL; will try to guess): ${GREEN}${var_val[$n]}${NORM}"
|
|
703
|
+
fi
|
|
704
|
+
elif [ "${var_name[$n]}" == "AWS_ACCESS" -o "${var_name[$n]}" == "AWS_SECRET" ]; then
|
|
705
|
+
if [ "$IAM_ROLE" != "" ];then
|
|
706
|
+
|
|
707
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (N/A if IAM role ${BOLD}$IAM_ROLE${NORM} has admin privs): ${GREEN}${var_val[$n]}${NORM}"
|
|
708
|
+
else
|
|
709
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (required): ${GREEN}${var_val[$n]}${NORM}"
|
|
710
|
+
fi
|
|
711
|
+
elif [ "${var_name[$n]}" == "MU_ADMIN_EMAIL" ]; then
|
|
712
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (required): ${GREEN}${var_val[$n]}${NORM}"
|
|
713
|
+
elif [ "${var_name[$n]}" == "MU_ADMIN_PW" ]; then
|
|
714
|
+
if [ "${var_val[$n]}" != "" -o -f "$MU_CHEF_CACHE/mu.user.key" ];then
|
|
715
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (required): ********"
|
|
716
|
+
else
|
|
717
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (required):"
|
|
718
|
+
fi
|
|
719
|
+
elif [ "${var_name[$n]}" == "JENKINS_ADMIN_PW" ]; then
|
|
720
|
+
if [ "${var_val[$n]}" != "" ];then
|
|
721
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (OPTIONAL): ********"
|
|
722
|
+
else
|
|
723
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (OPTIONAL):"
|
|
724
|
+
fi
|
|
725
|
+
elif [ "${var_name[$n]}" == "EC2SECGROUP" ]; then
|
|
726
|
+
if [ "$MY_VPC_ID" == "" ];then
|
|
727
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]} (OPTIONAL; will try to guess): ${GREEN}${var_val[$n]}${NORM}"
|
|
728
|
+
fi
|
|
729
|
+
else
|
|
730
|
+
echo " ${BOLD}$n${NORM}) ${var_name[$n]}: ${GREEN}${var_val[$n]}${NORM}"
|
|
731
|
+
fi
|
|
732
|
+
n=$[$n +1]
|
|
733
|
+
done
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
chef_client()
|
|
737
|
+
{
|
|
738
|
+
punch_tcp_hole 7443 # sometimes this isn't ready
|
|
739
|
+
upload_chef_artifacts -n -r $MU_REPO_NAME
|
|
740
|
+
status_message "chef-client $@"
|
|
741
|
+
|
|
742
|
+
chef_cert_name="`echo $CHEF_PUBLIC_IP | sed 's/\./_/g'`"
|
|
743
|
+
|
|
744
|
+
/bin/cp -f /opt/mu/var/ssl/Mu_CA.pem /etc/chef/trusted_certs/
|
|
745
|
+
if (knife ssl check -c /etc/chef/client.rb | egrep "^ERROR.*certificate");then
|
|
746
|
+
/bin/rm -f /etc/chef/trusted_certs/${chef_cert_name}.crt
|
|
747
|
+
/bin/rm -f /etc/chef/trusted_certs/${HOST_NAME}_platform-mu.crt
|
|
748
|
+
/opt/chef/bin/knife ssl fetch -c /etc/chef/client.rb
|
|
749
|
+
fi
|
|
750
|
+
# Same, but for /root/.chef/trusted_certs
|
|
751
|
+
/bin/cp -f /opt/mu/var/ssl/Mu_CA.pem /root/.chef/trusted_certs/
|
|
752
|
+
if (knife ssl check | egrep "^ERROR.*certificate");then
|
|
753
|
+
/bin/rm -f /root/.chef/trusted_certs/${chef_cert_name}.crt
|
|
754
|
+
/bin/rm -f /root/.chef/trusted_certs/${HOST_NAME}_platform-mu.crt
|
|
755
|
+
/opt/chef/bin/knife ssl fetch
|
|
756
|
+
fi
|
|
757
|
+
chef-client $@
|
|
758
|
+
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
###############################################################################
|
|
762
|
+
chef_server_ctl()
|
|
763
|
+
{
|
|
764
|
+
cmd=$1
|
|
765
|
+
pivotal_cfg_setup pivotal_cfg
|
|
766
|
+
status_message "/opt/opscode/bin/chef-server-ctl $cmd"
|
|
767
|
+
if ! /opt/opscode/bin/chef-server-ctl $cmd > /dev/null;then
|
|
768
|
+
status_message "Bad exit code from chef-server-ctl $cmd! Logs:"
|
|
769
|
+
(/opt/opscode/bin/chef-server-ctl tail) & pid=$!
|
|
770
|
+
pgid="`ps x -o \"%p %r %y %x %c \" | egrep \"^[[:space:]]*$pid[[:space:]]+\" | awk '{print $2}'`"
|
|
771
|
+
sleep 10 && kill -TERM -$pgid
|
|
772
|
+
fail_with_message "Bad exit code from chef-server-ctl $cmd! See above logs. $pid $pgid"
|
|
773
|
+
fi
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
###############################################################################
|
|
777
|
+
## Patch knife-windows to deal with Cygwin
|
|
778
|
+
patch_knife_windows()
|
|
779
|
+
{
|
|
780
|
+
kw_version="1.8.0"
|
|
781
|
+
|
|
782
|
+
for rubydir in $RUBY_INSTALL_DIR /opt/chef/embedded;do
|
|
783
|
+
if [ -d "$rubydir/lib/ruby/gems" ];then
|
|
784
|
+
# Remove gem versions other than the one we're mangling
|
|
785
|
+
for gem in `find $rubydir/lib/ruby/gems -type d -name 'knife-windows-*' | grep -v "knife-windows-$kw_version" | sed 's/.*\///'`;do
|
|
786
|
+
kw_badversion="`echo $gem | cut -d\- -f3`"
|
|
787
|
+
status_message "Removing knife-windows $kw_badversion from $rubydir"
|
|
788
|
+
$rubydir/bin/gem uninstall --force knife-windows --version $kw_badversion
|
|
789
|
+
done
|
|
790
|
+
knife_win_dir=`find $rubydir/lib/ruby/gems -type d -name knife-windows-$kw_version | grep -v /doc/knife-windows`
|
|
791
|
+
|
|
792
|
+
if [ "$knife_win_dir" == "" ];then
|
|
793
|
+
status_message "Installing knife-windows-$kw_version in $rubydir"
|
|
794
|
+
$rubydir/bin/gem install --force knife-windows --version $kw_version
|
|
795
|
+
knife_win_dir=`find $rubydir/lib/ruby/gems -type d -name knife-windows-$kw_version | grep -v /doc/knife-windows`
|
|
796
|
+
fi
|
|
797
|
+
if [ "`grep -i 'locate_config_value(:cygwin)' $knife_win_dir/lib/chef/knife/bootstrap_windows_base.rb`" == "" ];then
|
|
798
|
+
status_message "Patching Cygwin support into knife-windows-$kw_version in $rubydir"
|
|
799
|
+
cd $knife_win_dir && patch -p1 < $MU_LIBDIR/install/knife-windows-cygwin-$kw_version.patch || warning_message "Failed to patch knife-windows gem! Cygwin-based deploys of Windows hosts may not work!"
|
|
800
|
+
fi
|
|
801
|
+
# if [ "`grep -i '@config\[:node_ssl_verify_mode\]' $knife_win_dir/lib/chef/knife/core/windows_bootstrap_context.rb`" == "" ];then
|
|
802
|
+
# status_message "Patching Chef 12 support into knife-windows-$kw_version in $rubydir"
|
|
803
|
+
# cd $knife_win_dir && patch -p1 < $MU_LIBDIR/install/knife-windows-chef12-$kw_version.patch || warning_message "Failed to patch knife-windows gem! Cygwin-based deploys of Windows hosts may not work!"
|
|
804
|
+
# fi
|
|
805
|
+
if [ -e $rubydir ];then
|
|
806
|
+
find $rubydir/lib/ruby/gems -type f -exec chmod o+r {} \;
|
|
807
|
+
find $rubydir/lib/ruby/gems -type d -exec chmod o+rx {} \;
|
|
808
|
+
fi
|
|
809
|
+
fi
|
|
810
|
+
done
|
|
811
|
+
cd
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
###############################################################################
|
|
815
|
+
adjust_config_vars()
|
|
816
|
+
{
|
|
817
|
+
n=1
|
|
818
|
+
for v in $CONFIG_VARS;do
|
|
819
|
+
var_name[$n]=$v
|
|
820
|
+
var_val[$n]=${!v}
|
|
821
|
+
n=$[$n +1]
|
|
822
|
+
done
|
|
823
|
+
last_var=$n
|
|
824
|
+
|
|
825
|
+
print_setup_env_vars
|
|
826
|
+
bypass_aws_creds=0
|
|
827
|
+
while
|
|
828
|
+
read -p "Enter ${BOLD}O${NORM} to proceed with this config, or select a number to change. `echo $'\n> '`" config
|
|
829
|
+
do
|
|
830
|
+
echo ""
|
|
831
|
+
if [ "$config" == "O" -o "$config" == "o" ];then
|
|
832
|
+
validate_setup_env_vars
|
|
833
|
+
if [ $validate_errs == 0 ];then
|
|
834
|
+
break
|
|
835
|
+
fi
|
|
836
|
+
elif ! echo $config | egrep '^[0-9]{1,2}$' ; then
|
|
837
|
+
warning_message "Invalid option $config"
|
|
838
|
+
print_setup_env_vars
|
|
839
|
+
continue
|
|
840
|
+
else [ "${var_name[$config]}" != "" ] 2>/dev/null
|
|
841
|
+
# Process vars with password-style reads
|
|
842
|
+
if [ "${var_name[$config]}" == "MU_ADMIN_PW" ];then
|
|
843
|
+
read -s -p "Enter password for the ${BOLD}mu${NORM} admin user. `echo $'\n> '`" newval
|
|
844
|
+
elif [ "${var_name[$config]}" == "JENKINS_ADMIN_PW" ];then
|
|
845
|
+
read -s -p "Enter password for the ${BOLD}jenkins${NORM} admin user. `echo $'\n> '`" newval
|
|
846
|
+
else
|
|
847
|
+
|
|
848
|
+
# Process vars with normal style reads and special prompts
|
|
849
|
+
case ${var_name[$config]} in
|
|
850
|
+
"ADDTL_CHEF_REPOS")
|
|
851
|
+
echo "Enter the Github repos from which we'll pull Chef artifacts additional to those "
|
|
852
|
+
echo "from $MU_REPO. Delineate multiple repositories with spaces. Example:"
|
|
853
|
+
echo "${BOLD}eGT-Labs/mu-internal.git HHS/healthdata_platform.git${NORM}"
|
|
854
|
+
echo ""
|
|
855
|
+
;;&
|
|
856
|
+
"MU_ADMIN_EMAIL")
|
|
857
|
+
echo "Enter an email address for the internal 'mu' user."
|
|
858
|
+
echo "Note that you won't be able to reuse this address for a regular user. See also:"
|
|
859
|
+
echo "https://github.com/chef/chef-server/issues/59"
|
|
860
|
+
;;&
|
|
861
|
+
*)
|
|
862
|
+
# Everybody gets a read
|
|
863
|
+
read -p "Enter new value for ${BOLD}${var_name[$config]}${NORM}. `echo $'\n> '`" newval
|
|
864
|
+
;;
|
|
865
|
+
esac
|
|
866
|
+
fi
|
|
867
|
+
var_val[$config]=$newval
|
|
868
|
+
print_setup_env_vars
|
|
869
|
+
fi
|
|
870
|
+
done
|
|
871
|
+
|
|
872
|
+
n=1
|
|
873
|
+
homedir="`getent passwd \"$USER\" |cut -d: -f6`"
|
|
874
|
+
while [ "${var_name[$n]}" != "" ];do
|
|
875
|
+
if [ "${var_name[$n]}" != "PATH" ];then
|
|
876
|
+
eval "export ${var_name[$n]}=\"${var_val[$n]}\""
|
|
877
|
+
fi
|
|
878
|
+
# Set these in .murc too
|
|
879
|
+
if [ "${var_name[$n]}" == "AWS_ACCESS" -a "${var_val[$n]}" == "" ];then
|
|
880
|
+
echo "AWS_ACCESS is empty, leaving it unset" > /dev/null
|
|
881
|
+
elif [ "${var_name[$n]}" == "AWS_SECRET" -a "${var_val[$n]}" == "" ];then
|
|
882
|
+
echo "AWS_SECRET is empty, leaving it unset" > /dev/null
|
|
883
|
+
elif [ "${var_name[$n]}" != "MU_ADMIN_PW" -a "${var_name[$n]}" != "JENKINS_ADMIN_PW" ];then
|
|
884
|
+
update_murc ${var_name[$n]} "${var_val[$n]}"
|
|
885
|
+
fi
|
|
886
|
+
n=$[$n +1]
|
|
887
|
+
done
|
|
888
|
+
# Special cases- alternate env variable names for AWS credentials
|
|
889
|
+
if [ "$AWS_ACCESS" != "" ];then
|
|
890
|
+
update_murc AWS_ACCESS_KEY_ID $AWS_ACCESS
|
|
891
|
+
fi
|
|
892
|
+
if [ "$AWS_SECRET" != "" ];then
|
|
893
|
+
update_murc AWS_SECRET_ACCESS_KEY $AWS_SECRET
|
|
894
|
+
fi
|
|
895
|
+
for v in $RO_CONFIG_VARS;do
|
|
896
|
+
update_murc $v "${!v}"
|
|
897
|
+
done
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
###############################################################################
|
|
901
|
+
create_ssh_config()
|
|
902
|
+
{
|
|
903
|
+
mkdir -p $SSHDIR
|
|
904
|
+
touch $SSHDIR/config
|
|
905
|
+
chmod 600 $SSHDIR/config
|
|
906
|
+
# grep "^StrictHostKeyChecking " $SSHDIR/config || echo "StrictHostKeyChecking no" >> $SSHDIR/config
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
###############################################################################
|
|
910
|
+
set_up_github_ssh_key()
|
|
911
|
+
{
|
|
912
|
+
set -e
|
|
913
|
+
keyname="github-key-from-mu-install.$$"
|
|
914
|
+
echo "Paste a ${BOLD}private${NORM} SSH key for $1 here (^D to commit):"
|
|
915
|
+
cat > $SSHDIR/$keyname
|
|
916
|
+
chmod 400 $SSHDIR/$keyname
|
|
917
|
+
echo "Host github.com" >> $SSHDIR/config
|
|
918
|
+
echo " User git" >> $SSHDIR/config
|
|
919
|
+
echo " IdentityFile $SSHDIR/$keyname" >> $SSHDIR/config
|
|
920
|
+
echo " StrictHostKeyChecking no" >> $SSHDIR/config
|
|
921
|
+
set +e
|
|
922
|
+
export keyname
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
###############################################################################
|
|
926
|
+
# Only use this if called right after set_up_github_ssh_key. It's not smart.
|
|
927
|
+
expunge_github_ssh_key(){
|
|
928
|
+
keyname=$1
|
|
929
|
+
head -n -3 $SSHDIR/config > $SSHDIR/config.tmp.$$
|
|
930
|
+
/bin/mv -f $SSHDIR/config.tmp.$$ $SSHDIR/config
|
|
931
|
+
/bin/rm -f $keyname
|
|
932
|
+
unset keyname
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
fix_platform_repo_permissions()
|
|
936
|
+
{
|
|
937
|
+
chefdir="$1"
|
|
938
|
+
if [ "$chefdir" != "" ];then
|
|
939
|
+
chmod go+rx $chefdir
|
|
940
|
+
for subdir in applications cookbooks site_cookbooks roles environments data_bags modules Berks* README.md LICENSE.md demo;do
|
|
941
|
+
if [ -e "$chefdir/$subdir" ];then
|
|
942
|
+
find "$chefdir/$subdir" -type d -exec chmod go+rx {} \;
|
|
943
|
+
find "$chefdir/$subdir" -type f -exec chmod go+r {} \;
|
|
944
|
+
fi
|
|
945
|
+
done
|
|
946
|
+
for subdir in bin utils;do
|
|
947
|
+
if [ -e "$chefdir/$subdir" ];then
|
|
948
|
+
find "$chefdir/$subdir" -type d -exec chmod go+rx {} \;
|
|
949
|
+
find "$chefdir/$subdir" -type f -exec chmod go+rx {} \;
|
|
950
|
+
fi
|
|
951
|
+
done
|
|
952
|
+
fi
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
###############################################################################
|
|
956
|
+
clone_repository()
|
|
957
|
+
{
|
|
958
|
+
set +e
|
|
959
|
+
repo=$1
|
|
960
|
+
clone_path=$2
|
|
961
|
+
|
|
962
|
+
clone_ssh="git clone git@github.com:$repo $clone_path"
|
|
963
|
+
# This is ugly. Adding a 30 second timeout for HTTPS clone so we don't hang if prompted for a username and/or password.
|
|
964
|
+
clone_https="timeout 30 git clone https://github.com/$repo $clone_path"
|
|
965
|
+
mkdir -p $clone_path
|
|
966
|
+
if [ "$(ls -A $clone_path)" ];then
|
|
967
|
+
echo "$clone_path exists and is non-empty. I'm going to assume the repo has already been cloned..."
|
|
968
|
+
sleep 3
|
|
969
|
+
else
|
|
970
|
+
mkdir -p $SSHDIR
|
|
971
|
+
echo "Attempting to clone $repo without private key."
|
|
972
|
+
echo $clone_https
|
|
973
|
+
$clone_https 2>&1 > /dev/null
|
|
974
|
+
if [ "$(ls -A $clone_path)" ];then
|
|
975
|
+
echo "$clone_path exists and is not empty. I'm going to assume $repo was cloned successfully without a private key"
|
|
976
|
+
else
|
|
977
|
+
if [ "`grep ^github.com $SSHDIR/known_hosts 2>/dev/null`" != "" ];then
|
|
978
|
+
echo "Attempting to clone $repo with existing keys..."
|
|
979
|
+
echo $clone_ssh
|
|
980
|
+
$clone_ssh 2>&1 > /dev/null
|
|
981
|
+
fi
|
|
982
|
+
if [ $? != 0 -o "`grep ^github.com $SSHDIR/known_hosts 2>/dev/null`" == "" ];then
|
|
983
|
+
echo ""
|
|
984
|
+
authtype=""
|
|
985
|
+
echo "We'll need a key for access to ${BOLD}$repo${NORM}."
|
|
986
|
+
if [ "$use_defaults" != "" ];then
|
|
987
|
+
fail_with_message "In non-interactive mode, but I need Git credentials! Run without -n."
|
|
988
|
+
fi
|
|
989
|
+
while /bin/true ;do
|
|
990
|
+
rm -rf $clone_path
|
|
991
|
+
expunge_github_ssh_key $keyname
|
|
992
|
+
echo ""
|
|
993
|
+
set_up_github_ssh_key $repo
|
|
994
|
+
echo $clone_ssh
|
|
995
|
+
$clone_ssh && break
|
|
996
|
+
done
|
|
997
|
+
fi
|
|
998
|
+
fi
|
|
999
|
+
fi
|
|
1000
|
+
|
|
1001
|
+
fix_platform_repo_permissions "$clone_path"
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
###############################################################################
|
|
1005
|
+
set_hostname()
|
|
1006
|
+
{
|
|
1007
|
+
if [ "$HOST_NAME" != "`hostname -s`" ];then
|
|
1008
|
+
hostname $HOST_NAME
|
|
1009
|
+
sed -i "s/^HOST_NAME=.*/HOST_NAME=$HOST_NAME/" /etc/sysconfig/network
|
|
1010
|
+
|
|
1011
|
+
if [ $DIST_VERSION == 7 ];then
|
|
1012
|
+
hostnamectl set-hostname $HOST_NAME && systemctl restart systemd-hostnamed
|
|
1013
|
+
fi
|
|
1014
|
+
fi
|
|
1015
|
+
if ! grep "^$MY_PRIVATE_IP $HOST_NAME.platform-mu $HOST_NAME MU-MASTER" /etc/hosts > /dev/null;then
|
|
1016
|
+
sed -i "/ $HOST_NAME/d" /etc/hosts
|
|
1017
|
+
sed -i "/^$MY_PRIVATE_IP/d" /etc/hosts
|
|
1018
|
+
echo "$MY_PRIVATE_IP $HOST_NAME.platform-mu $HOST_NAME MU-MASTER" >> /etc/hosts
|
|
1019
|
+
fi
|
|
1020
|
+
if [ "$MY_PRIVATE_IP" != "$MY_PUBLIC_IP" -a "$MY_PUBLIC_IP" != "" ];then
|
|
1021
|
+
if ! grep "^$MY_PUBLIC_IP $HOST_NAME.platform-mu $HOST_NAME MU-MASTER" /etc/hosts > /dev/null;then
|
|
1022
|
+
sed -i "/ $HOST_NAME/d" /etc/hosts
|
|
1023
|
+
sed -i "/^$MY_PUBLIC_IP/d" /etc/hosts
|
|
1024
|
+
echo "$MY_PRIVATE_IP $HOST_NAME.platform-mu $HOST_NAME MU-MASTER" >> /etc/hosts
|
|
1025
|
+
echo "$MY_PUBLIC_IP $HOST_NAME.platform-mu $HOST_NAME MU-MASTER" >> /etc/hosts
|
|
1026
|
+
fi
|
|
1027
|
+
fi
|
|
1028
|
+
export HOST_NAME
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
###############################################################################
|
|
1032
|
+
set_logbucket()
|
|
1033
|
+
{
|
|
1034
|
+
if [ "$LOG_BUCKET_NAME" == "" ];then
|
|
1035
|
+
LOG_BUCKET_NAME="mu-logs-${HOST_NAME}-${MY_INSTANCE_ID}"
|
|
1036
|
+
fi
|
|
1037
|
+
export LOG_BUCKET_NAME
|
|
1038
|
+
update_murc LOG_BUCKET_NAME $LOG_BUCKET_NAME
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
###############################################################################
|
|
1043
|
+
install_system_packages()
|
|
1044
|
+
{
|
|
1045
|
+
if [ ! -f /etc/yum.repos.d/epel.repo ];then
|
|
1046
|
+
status_message "Installing ${BOLD}EPEL${NORM}"
|
|
1047
|
+
rpm -ivh ${EPEL_RPM}
|
|
1048
|
+
fi
|
|
1049
|
+
|
|
1050
|
+
uninstall_me=""
|
|
1051
|
+
for pkg in $DEL_PACKAGES;do
|
|
1052
|
+
rpm -q $pkg 2>&1 > /dev/null && uninstall_me="${install_me} $pkg"
|
|
1053
|
+
done
|
|
1054
|
+
if [ "$uninstall_me" != "" ];then
|
|
1055
|
+
yum -y erase ${uninstall_me} || exit 1
|
|
1056
|
+
fi
|
|
1057
|
+
|
|
1058
|
+
install_me=""
|
|
1059
|
+
for pkg in $PACKAGES;do
|
|
1060
|
+
rpm -q $pkg 2>&1 > /dev/null || install_me="${install_me} $pkg"
|
|
1061
|
+
done
|
|
1062
|
+
enables=""
|
|
1063
|
+
for r in rhui-REGION-rhel-server-releases-optional epel extras;do
|
|
1064
|
+
if grep $r /etc/yum.repos.d/* > /dev/null;then
|
|
1065
|
+
enables="${enables} --enablerepo=$r"
|
|
1066
|
+
fi
|
|
1067
|
+
done
|
|
1068
|
+
if [ "$install_me" != "" ];then
|
|
1069
|
+
status_message "Installing ${BOLD}base packages${NORM}"
|
|
1070
|
+
yum -y install ${enables} ${install_me} || exit 1
|
|
1071
|
+
fi
|
|
1072
|
+
|
|
1073
|
+
# if [ $DIST_VERSION == 7 ];then
|
|
1074
|
+
# for pkg in $GECODE_RPMS;do
|
|
1075
|
+
# rpm -ivh $pkg
|
|
1076
|
+
# done
|
|
1077
|
+
# fi
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
###############################################################################
|
|
1081
|
+
set_bash_defaults()
|
|
1082
|
+
{
|
|
1083
|
+
status_message "Initializing ${BOLD}shell environment${NORM}"
|
|
1084
|
+
|
|
1085
|
+
# Stange-isms, maybe these don't belong here.
|
|
1086
|
+
grep "alias vi=" $HOMEDIR/.bashrc > /dev/null || echo "alias vi=vim" >> $HOMEDIR/.bashrc
|
|
1087
|
+
grep "export EDITOR=vim" $HOMEDIR/.bashrc > /dev/null || echo "export EDITOR=vim" >> $HOMEDIR/.bashrc
|
|
1088
|
+
|
|
1089
|
+
update_murc PATH "$MU_INSTALLDIR/bin:/usr/local/ruby-current/bin:\${PATH}:/opt/opscode/embedded/bin"
|
|
1090
|
+
|
|
1091
|
+
grep "^source $MURC" $HOMEDIR/.bashrc > /dev/null || echo "source $MURC" >> $HOMEDIR/.bashrc
|
|
1092
|
+
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
###############################################################################
|
|
1097
|
+
clone_mu_repository()
|
|
1098
|
+
{
|
|
1099
|
+
rpm -q git > /dev/null || yum -y install git || exit 1
|
|
1100
|
+
status_message "Cloning ${BOLD}$MU_REPO${NORM} to $MU_LIBDIR"
|
|
1101
|
+
clone_repository $MU_REPO "$MU_LIBDIR"
|
|
1102
|
+
status_message "Checking out $MUBRANCH"
|
|
1103
|
+
cd "$MU_LIBDIR" && git checkout "$MUBRANCH"
|
|
1104
|
+
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
|
|
1108
|
+
###############################################################################
|
|
1109
|
+
## Go fetch a current version of Ruby. Some of our tools will need this,
|
|
1110
|
+
## and this isn't the same as the Ruby that is bundled with Chef, which
|
|
1111
|
+
## will reside in its own /opt/chef sandbox and should be left unmolested.
|
|
1112
|
+
install_ruby()
|
|
1113
|
+
{
|
|
1114
|
+
if [ "$1" == "purgeold" ];then
|
|
1115
|
+
status_message "Purging existing ${BOLD}$RUBY_VERSION${NORM} package"
|
|
1116
|
+
rpm -e $RUBY_VERSION
|
|
1117
|
+
rm -rf $RUBY_INSTALL_DIR
|
|
1118
|
+
fi
|
|
1119
|
+
status_message "Installing ${BOLD}$RUBY_VERSION${NORM}"
|
|
1120
|
+
|
|
1121
|
+
if rpm -q ruby > /dev/null ;then
|
|
1122
|
+
yum -y erase ruby
|
|
1123
|
+
fi
|
|
1124
|
+
|
|
1125
|
+
if ! rpm -q $RUBY_VERSION > /dev/null ;then
|
|
1126
|
+
if [ "$IS_AMAZON" != "1" ];then
|
|
1127
|
+
yum -y install $RUBY_RPM
|
|
1128
|
+
else
|
|
1129
|
+
rpm -ivh --nodeps $RUBY_RPM # XXX hack workaround for spurious dependency
|
|
1130
|
+
fi
|
|
1131
|
+
fi
|
|
1132
|
+
rm -f /usr/local/ruby-current
|
|
1133
|
+
ln -s $RUBY_INSTALL_DIR /usr/local/ruby-current
|
|
1134
|
+
|
|
1135
|
+
# Init Mu's gem library now that it has a Ruby to use.
|
|
1136
|
+
export USE_SYSTEM_GECODE=1
|
|
1137
|
+
if [ ! -f $RUBY_INSTALL_DIR/bin/bundle ];then
|
|
1138
|
+
set -e
|
|
1139
|
+
$RUBY_INSTALL_DIR/bin/gem install bundler
|
|
1140
|
+
cd $MU_LIBDIR/modules && $RUBY_INSTALL_DIR/bin/bundle install
|
|
1141
|
+
set +e
|
|
1142
|
+
fi
|
|
1143
|
+
add_chef_support_gems $RUBY_INSTALL_DIR
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
###############################################################################
|
|
1147
|
+
## Fetch cookbooks managed by berkshelf
|
|
1148
|
+
install_cookbooks()
|
|
1149
|
+
{
|
|
1150
|
+
status_message "Installing Berkshelf cookbooks specified in $MU_LIBDIR/Berksfile"
|
|
1151
|
+
rm -rf $HOMEDIR/.berkshelf/cookbooks/*
|
|
1152
|
+
|
|
1153
|
+
cd $MU_LIBDIR && ( /usr/local/ruby-current/bin/berks install || /usr/local/ruby-current/bin/berks update )
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
###############################################################################
|
|
1157
|
+
## Let's use the AWS CLI tools in lieu of... well, all the other crufty
|
|
1158
|
+
## tools we might try.
|
|
1159
|
+
install_awscli()
|
|
1160
|
+
{
|
|
1161
|
+
status_message "Installing ${BOLD}awscli${NORM}"
|
|
1162
|
+
|
|
1163
|
+
test -x /usr/bin/aws || pip install awscli
|
|
1164
|
+
if [ ! -f $HOMEDIR/.aws/config ];then
|
|
1165
|
+
mkdir -p $HOMEDIR/.aws
|
|
1166
|
+
cat > $HOMEDIR/.aws/config <<EOF
|
|
1167
|
+
[default]
|
|
1168
|
+
region = $EC2_REGION
|
|
1169
|
+
EOF
|
|
1170
|
+
if [ "$AWS_SECRET" != "" -a "$AWS_ACCESS" != "" ];then
|
|
1171
|
+
echo "aws_access_key_id = $AWS_ACCESS" >> $HOMEDIR/.aws/config
|
|
1172
|
+
echo "aws_secret_access_key = $AWS_SECRET" >> $HOMEDIR/.aws/config
|
|
1173
|
+
else
|
|
1174
|
+
echo "${BOLD}AWS_SECRET${NORM} or ${BOLD}AWS_ACCESS${NORM} aren't set!"
|
|
1175
|
+
echo "Note that ${BOLD}awscli${NORM} will not work without credentials, unless you have configured"
|
|
1176
|
+
echo "${BOLD}IAM Roles${NORM} to allow us to manage resources."
|
|
1177
|
+
echo ""
|
|
1178
|
+
fi
|
|
1179
|
+
else
|
|
1180
|
+
echo "Looks like /usr/bin/aws is already present."
|
|
1181
|
+
fi
|
|
1182
|
+
test -f $HOMEDIR/.aws/config && chmod 400 $HOMEDIR/.aws/config
|
|
1183
|
+
|
|
1184
|
+
if ! aws ec2 describe-instances --instance-ids $MY_INSTANCE_ID >/dev/null;then
|
|
1185
|
+
warning_message "I can't run basic AWS commands with awscli!" "Tried: aws ec2 describe-instances --instance-ids $MY_INSTANCE_ID"
|
|
1186
|
+
fi
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
###############################################################################
|
|
1190
|
+
## Create our internal-use ".platform-mu" private DNS zone
|
|
1191
|
+
create_private_dns_zone()
|
|
1192
|
+
{
|
|
1193
|
+
status_message "Creating private ${BOLD}.platform-mu${NORM} DNS zone"
|
|
1194
|
+
|
|
1195
|
+
$MU_LIBDIR/bin/mu-aws-setup -d
|
|
1196
|
+
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
###############################################################################
|
|
1200
|
+
## Associate our preferred public IP address, if applicable.
|
|
1201
|
+
associate_public_ip()
|
|
1202
|
+
{
|
|
1203
|
+
status_message "Setting IP to ${BOLD}$CHEF_PUBLIC_IP${NORM}"
|
|
1204
|
+
|
|
1205
|
+
$MU_LIBDIR/bin/mu-aws-setup -i
|
|
1206
|
+
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
###############################################################################
|
|
1210
|
+
configure_ec2_security_group()
|
|
1211
|
+
{
|
|
1212
|
+
status_message "Detecting ${BOLD}EC2 Security Group${NORM} configuration"
|
|
1213
|
+
set -e
|
|
1214
|
+
EC2SECGROUP="`$MU_LIBDIR/bin/mu-aws-setup -s | grep 'Setting' | cut -d'(' -f2 | cut -d')' -f1`"
|
|
1215
|
+
set +e
|
|
1216
|
+
update_murc EC2SECGROUP $EC2SECGROUP
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
###############################################################################
|
|
1221
|
+
punch_tcp_hole()
|
|
1222
|
+
{
|
|
1223
|
+
port=$1
|
|
1224
|
+
# status_message "Opening firewall for port ${BOLD}$port${NORM}"
|
|
1225
|
+
/sbin/iptables -nL | egrep "^ACCEPT.*dpt:$port($| )" > /dev/null || ( /sbin/iptables -I INPUT -p tcp --dport $port -j ACCEPT && service iptables save )
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
###############################################################################
|
|
1229
|
+
## Install gems for Rubies that use Chef
|
|
1230
|
+
add_chef_support_gems()
|
|
1231
|
+
{
|
|
1232
|
+
rubydir=$1
|
|
1233
|
+
set -e
|
|
1234
|
+
$rubydir/bin/gem list | grep '^bundler' > /dev/null || $rubydir/bin/gem install bundler --no-rdoc --no-ri
|
|
1235
|
+
|
|
1236
|
+
status_message "Installing support gems in $rubydir"
|
|
1237
|
+
|
|
1238
|
+
cd $MU_LIBDIR/modules && $rubydir/bin/bundle install
|
|
1239
|
+
$rubydir/bin/gem update --system
|
|
1240
|
+
set +e
|
|
1241
|
+
|
|
1242
|
+
find $rubydir/ -type f -exec chmod go+r {} \;
|
|
1243
|
+
find $rubydir/bin -type f -exec chmod go+rx {} \;
|
|
1244
|
+
find $rubydir/ -type d -exec chmod go+rx {} \;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
###############################################################################
|
|
1248
|
+
## Set up knife.rb for root
|
|
1249
|
+
set_knife_rb()
|
|
1250
|
+
{
|
|
1251
|
+
basepath="$1"
|
|
1252
|
+
knife_user="$2"
|
|
1253
|
+
url="$3"
|
|
1254
|
+
chef_cache="$MU_CHEF_CACHE"
|
|
1255
|
+
|
|
1256
|
+
if [ "$knife_user" == "" ];then
|
|
1257
|
+
knife_user="mu"
|
|
1258
|
+
elif [ "$knife_user" != "mu" ];then
|
|
1259
|
+
chef_cache="`getent passwd \"$association_user\" |cut -d: -f6`/.chef"
|
|
1260
|
+
fi
|
|
1261
|
+
mkdir -p $chef_cache
|
|
1262
|
+
cat /dev/null > $chef_cache/knife.rb
|
|
1263
|
+
# XXX verify_api_cert ssl_verify_mode shouldn't have to be set like this.
|
|
1264
|
+
# don't release with this grotesquely insecure configuration.
|
|
1265
|
+
cat > $chef_cache/knife.rb.tmp.$$ << EOF
|
|
1266
|
+
log_level :info
|
|
1267
|
+
log_location STDOUT
|
|
1268
|
+
node_name '$knife_user'
|
|
1269
|
+
client_key '$chef_cache/$knife_user.user.key'
|
|
1270
|
+
validation_client_name '$knife_user-validator'
|
|
1271
|
+
validation_key '$chef_cache/$knife_user.org.key'
|
|
1272
|
+
chef_server_url "https://${CHEF_PUBLIC_IP}:7443/$basepath"
|
|
1273
|
+
chef_server_root "https://${CHEF_PUBLIC_IP}:7443/$basepath"
|
|
1274
|
+
syntax_check_cache_path '$chef_cache/syntax_check_cache'
|
|
1275
|
+
cookbook_path [ '$chef_cache/cookbooks', '$chef_cache/site_cookbooks' ]
|
|
1276
|
+
knife[:vault_mode] = 'client'
|
|
1277
|
+
knife[:vault_admins] = ['$knife_user']
|
|
1278
|
+
# verify_api_cert false
|
|
1279
|
+
# ssl_verify_mode :verify_none
|
|
1280
|
+
EOF
|
|
1281
|
+
mv -f $chef_cache/knife.rb.tmp.$$ $chef_cache/knife.rb
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
###############################################################################
|
|
1285
|
+
## Install the Chef Omnibus package.
|
|
1286
|
+
install_chef()
|
|
1287
|
+
{
|
|
1288
|
+
punch_tcp_hole 80
|
|
1289
|
+
punch_tcp_hole 443
|
|
1290
|
+
punch_tcp_hole 7443
|
|
1291
|
+
|
|
1292
|
+
# Sometimes we get a half-deleted Chef package in our way
|
|
1293
|
+
if [ ! -d /opt/chef ];then
|
|
1294
|
+
rpm -e chef
|
|
1295
|
+
fi
|
|
1296
|
+
# Chef Server 12 inexplicably ships with old, broken versions of the
|
|
1297
|
+
# client. Install something sane.
|
|
1298
|
+
if ! rpm -q $CHEF_CLIENT_PKG > /dev/null ;then
|
|
1299
|
+
status_message "Installing current Chef client"
|
|
1300
|
+
yum -y erase chef || rpm -e chef # one of these will get it
|
|
1301
|
+
rm -rf /opt/chef # and stay out
|
|
1302
|
+
curl https://www.chef.io/chef/install.sh > /root/chef-install.sh
|
|
1303
|
+
sh /root/chef-install.sh -v $CHEF_CLIENT_VERSION
|
|
1304
|
+
fi
|
|
1305
|
+
if [ -f /opt/chef/embedded/bin/gem ];then
|
|
1306
|
+
add_chef_support_gems /opt/chef/embedded
|
|
1307
|
+
fi
|
|
1308
|
+
port="`grep \"'ssl_port'\" /etc/opscode/chef-server.rb | awk '{print $3}'`"
|
|
1309
|
+
|
|
1310
|
+
if [ "$port" == "" ];then
|
|
1311
|
+
port="443"
|
|
1312
|
+
service httpd stop # sits on 443, and Chef is stupid; disable temporarily
|
|
1313
|
+
fi
|
|
1314
|
+
|
|
1315
|
+
set_knife_rb organizations/mu mu "https://${CHEF_PUBLIC_IP}:$port"
|
|
1316
|
+
|
|
1317
|
+
# Now Chef server
|
|
1318
|
+
if ! rpm -q chef-server-core > /dev/null ;then
|
|
1319
|
+
if rpm -q chef-server > /dev/null ;then
|
|
1320
|
+
/opt/chef-server/bin/chef-server-ctl stop
|
|
1321
|
+
fi
|
|
1322
|
+
status_message "Installing ${BOLD}Chef Server${NORM} (listen port: ${port})"
|
|
1323
|
+
rpm -ivh $OPSCODE_CHEF_DL
|
|
1324
|
+
find /opt/opscode/embedded/lib/ruby -type f -exec chmod o+r {} \;
|
|
1325
|
+
find /opt/opscode/embedded/lib/ruby -type d -exec chmod o+rx {} \;
|
|
1326
|
+
pivotal_cfg_setup pivotal_cfg $port
|
|
1327
|
+
/opt/opscode/bin/chef-server-ctl reconfigure
|
|
1328
|
+
chef_self_test=1
|
|
1329
|
+
elif [ ! -f "/var/opt/opscode/nginx/ca/${CHEF_PUBLIC_IP}.crt" ];then
|
|
1330
|
+
status_message "Hostname or IP may have changed, reconfiguring Chef (listen port: ${port})"
|
|
1331
|
+
pivotal_cfg_setup pivotal_cfg $port
|
|
1332
|
+
/opt/opscode/bin/chef-server-ctl restart
|
|
1333
|
+
/opt/opscode/bin/chef-server-ctl reconfigure
|
|
1334
|
+
knife ssl fetch -u pivotal -k /etc/opscode/pivotal.pem -s https://${CHEF_PUBLIC_IP}:$port > /dev/null 2>&1
|
|
1335
|
+
rm -f /etc/chef/client.*
|
|
1336
|
+
knife node delete -y MU-MASTER
|
|
1337
|
+
knife client delete -y MU-MASTER
|
|
1338
|
+
chef_self_test=1
|
|
1339
|
+
fi
|
|
1340
|
+
# add_chef_support_gems /opt/opscode/embedded
|
|
1341
|
+
pivotal_cfg_setup pivotal_cfg $port
|
|
1342
|
+
|
|
1343
|
+
knife ssl fetch $pivotal_cfg > /dev/null 2>&1
|
|
1344
|
+
|
|
1345
|
+
list_chef_users ext_chef_users
|
|
1346
|
+
|
|
1347
|
+
umask 0077
|
|
1348
|
+
# if ! ( echo "$ext_chef_users" | egrep "(^| )mu( |$)" > /dev/null );then
|
|
1349
|
+
if [ ! -f "$MU_DATADIR/users/mu/mu.user.key" -o ! -f "$MU_CHEF_CACHE/mu.org.key" ];then
|
|
1350
|
+
manage_chef_user "mu" "$MU_ADMIN_PW" "Mu Master" "$MU_ADMIN_EMAIL" "" "1" "" "1"
|
|
1351
|
+
fi
|
|
1352
|
+
mkdir -p "$MU_DATADIR/users/mu"
|
|
1353
|
+
echo "$MU_ADMIN_EMAIL" > "$MU_DATADIR/users/mu/email"
|
|
1354
|
+
echo "Mu Master" > "$MU_DATADIR/users/mu/realname"
|
|
1355
|
+
if [ ! -f "$MU_DATADIR/users/mu/htpasswd" -a "$MU_ADMIN_PW" != "" ];then
|
|
1356
|
+
# XXX this is sloppy as hell, from a security standpoint
|
|
1357
|
+
/usr/bin/htpasswd -c -b -m "$MU_DATADIR/users/mu/htpasswd" "mu" "$MU_ADMIN_PW"
|
|
1358
|
+
fi
|
|
1359
|
+
|
|
1360
|
+
set_knife_rb organizations/mu mu "https://${CHEF_PUBLIC_IP}:$port"
|
|
1361
|
+
|
|
1362
|
+
/opt/chef/bin/knife ssl fetch -s https://$CHEF_PUBLIC_IP:$port > /dev/null 2>&1
|
|
1363
|
+
umask 0022
|
|
1364
|
+
|
|
1365
|
+
cur_chef="`rpm -q chef-server-core`"
|
|
1366
|
+
if [ "$cur_chef" != "$OPSCODE_CHEF_PKG" ];then
|
|
1367
|
+
status_message "Upgrading ${BOLD}Chef Server${NORM}"
|
|
1368
|
+
if rpm -Uvh $OPSCODE_CHEF_DL;then
|
|
1369
|
+
chef_self_test=1
|
|
1370
|
+
/opt/opscode/bin/chef-server-ctl upgrade
|
|
1371
|
+
find /opt/opscode/embedded/lib/ruby -type f -exec chmod o+r {} \;
|
|
1372
|
+
find /opt/opscode/embedded/lib/ruby -type d -exec chmod o+rx {} \;
|
|
1373
|
+
/opt/opscode/bin/chef-server-ctl reconfigure
|
|
1374
|
+
# add_chef_support_gems /opt/opscode/embedded
|
|
1375
|
+
$RUBY_INSTALLDIR/bin/bundle update chef
|
|
1376
|
+
/opt/opscode/bin/chef-server-ctl start
|
|
1377
|
+
else
|
|
1378
|
+
warning_message "Failed to upgrade to package $OPSCODE_CHEF_DL"
|
|
1379
|
+
fi
|
|
1380
|
+
fi
|
|
1381
|
+
|
|
1382
|
+
export CHEF_PUBLIC_IP
|
|
1383
|
+
if ! ( echo $PATH | egrep ":/opt/opscode/embedded/bin(:|$)" > /dev/null );then
|
|
1384
|
+
export PATH="$MU_INSTALLDIR/bin:${PATH}:/opt/opscode/embedded/bin"
|
|
1385
|
+
fi
|
|
1386
|
+
|
|
1387
|
+
|
|
1388
|
+
mkdir -p /etc/opscode
|
|
1389
|
+
cat >> /etc/opscode/chef-server.rb.tmp.$$ << EOF
|
|
1390
|
+
#
|
|
1391
|
+
# Mu Chef Server Settings
|
|
1392
|
+
#
|
|
1393
|
+
server_name="$CHEF_PUBLIC_IP"
|
|
1394
|
+
|
|
1395
|
+
api_fqdn server_name
|
|
1396
|
+
|
|
1397
|
+
nginx['server_name'] = server_name
|
|
1398
|
+
nginx['enable_non_ssl'] = false
|
|
1399
|
+
nginx['non_ssl_port'] = 81
|
|
1400
|
+
nginx['ssl_port'] = 7443
|
|
1401
|
+
nginx['ssl_ciphers'] = "HIGH:MEDIUM:!LOW:!kEDH:!aNULL:!ADH:!eNULL:!EXP:!SSLv2:!SEED:!CAMELLIA:!PSK"
|
|
1402
|
+
nginx['ssl_protocols'] = "TLSv1 TLSv1.1 TLSv1.2"
|
|
1403
|
+
nginx['ssl_certificate'] = "$MU_SSL_CERT"
|
|
1404
|
+
nginx['ssl_certificate_key'] = "$MU_SSL_KEY"
|
|
1405
|
+
bookshelf['external_url'] = "https://"+server_name+":7443"
|
|
1406
|
+
bookshelf['vip_port'] = 7443
|
|
1407
|
+
EOF
|
|
1408
|
+
if [ ! -f /etc/opscode/chef-server.rb -o "`diff /etc/opscode/chef-server.rb /etc/opscode/chef-server.rb.tmp.$$`" != "" ];then
|
|
1409
|
+
/bin/mv -f /etc/opscode/chef-server.rb.tmp.$$ /etc/opscode/chef-server.rb
|
|
1410
|
+
chef_server_ctl reconfigure
|
|
1411
|
+
else
|
|
1412
|
+
/bin/rm -f /etc/opscode/chef-server.rb.tmp.$$
|
|
1413
|
+
fi
|
|
1414
|
+
|
|
1415
|
+
# XXX workaround for vile chef bug, see:
|
|
1416
|
+
# https://github.com/chef/chef-server/issues/50
|
|
1417
|
+
# if ! grep "s3_url, \"https:\/\/${HOST_NAME}.platform-mu:7443\"" /var/opt/opscode/opscode-erchef/sys.config > /dev/null;then
|
|
1418
|
+
# status_message "Switching ${BOLD}Chef Server${NORM} to port ${BOLD}7443${NORM}"
|
|
1419
|
+
# /bin/sed -i "s/s3_url, \"https:\/\/${HOST_NAME}.platform-mu\"/s3_url, \"https:\/\/${HOST_NAME}.platform-mu:7443\"/" /var/opt/opscode/opscode-erchef/sys.config
|
|
1420
|
+
# chef_server_ctl restart
|
|
1421
|
+
# fi
|
|
1422
|
+
|
|
1423
|
+
set_knife_rb organizations/mu mu "https://${CHEF_PUBLIC_IP}:7443"
|
|
1424
|
+
/opt/chef/bin/knife ssl fetch -s https://$CHEF_PUBLIC_IP:7443 > /dev/null 2>&1
|
|
1425
|
+
/opt/chef/bin/knife ssl fetch -s https://localhost:7443 > /dev/null 2>&1
|
|
1426
|
+
/opt/chef/bin/knife ssl fetch -s https://127.0.0.1:7443 > /dev/null 2>&1
|
|
1427
|
+
|
|
1428
|
+
pivotal_cfg_setup pivotal_cfg 7443
|
|
1429
|
+
|
|
1430
|
+
cat >> /etc/chef/client.rb.tmp.$$ << EOF
|
|
1431
|
+
log_location STDOUT
|
|
1432
|
+
chef_server_url "https://${CHEF_PUBLIC_IP}:7443/organizations/mu"
|
|
1433
|
+
validation_client_name "mu-validator"
|
|
1434
|
+
node_name "MU-MASTER"
|
|
1435
|
+
trusted_certs_dir "/etc/chef/trusted_certs"
|
|
1436
|
+
EOF
|
|
1437
|
+
if [ -f /etc/chef/client.rb -a "`diff /etc/chef/client.rb /etc/chef/client.rb.tmp.$$`" != "" ];then
|
|
1438
|
+
/bin/cp -f /etc/chef/client.rb.tmp.$$ /etc/chef/client.rb
|
|
1439
|
+
fi
|
|
1440
|
+
if [ -f /root/.chef/client.rb -a "`diff /root/.chef/client.rb /etc/chef/client.rb.tmp.$$`" != "" ];then
|
|
1441
|
+
/bin/cp -f /etc/chef/client.rb.tmp.$$ /root/.chef/client.rb
|
|
1442
|
+
fi
|
|
1443
|
+
/bin/rm -f /etc/chef/client.rb.tmp.$$ /etc/chef/validation.pem
|
|
1444
|
+
/sbin/service httpd start 2>&1 > /dev/null
|
|
1445
|
+
punch_tcp_hole 7443 # sometimes this isn't ready
|
|
1446
|
+
knife vault create scratchpad dummy '{ "merp":"meep" }'
|
|
1447
|
+
knife vault delete -y scratchpad dummy
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
upload_chef_artifacts()
|
|
1452
|
+
{
|
|
1453
|
+
punch_tcp_hole 7443 # sometimes this isn't ready
|
|
1454
|
+
if [ "$chef_artifacts_uploaded" != "1" ];then
|
|
1455
|
+
if ! echo "$@" | egrep -- "-n" ;then
|
|
1456
|
+
rm -rf $HOMEDIR/.berkshelf
|
|
1457
|
+
rm -rf $HOMEDIR/.chef/cookbooks
|
|
1458
|
+
rm -rf $HOMEDIR/.chef/site_cookbooks
|
|
1459
|
+
rm -rf $MU_LIBDIR/cookbooks/cap-*
|
|
1460
|
+
for a in cookbooks site_bookbooks data_bags roles environments;do
|
|
1461
|
+
/bin/rm -rf $MU_CHEF_CACHE/$a
|
|
1462
|
+
done
|
|
1463
|
+
fi
|
|
1464
|
+
/opt/chef/bin/knife ssl fetch -s https://$CHEF_PUBLIC_IP > /dev/null 2>&1
|
|
1465
|
+
status_message "Syncing Chef artifacts to running server..."
|
|
1466
|
+
$MU_LIBDIR/bin/mu-upload-chef-artifacts $@
|
|
1467
|
+
chef_artifacts_uploaded_by_installer=1
|
|
1468
|
+
fi
|
|
1469
|
+
chef_artifacts_uploaded=1
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
###############################################################################
|
|
1473
|
+
## Set us up to use ~/.chef, and knife accordingly.
|
|
1474
|
+
setup_chef_cache()
|
|
1475
|
+
{
|
|
1476
|
+
upload_chef_artifacts=$1
|
|
1477
|
+
status_message "Setting up local Chef cache in ${BOLD}$MU_CHEF_CACHE${NORM}"
|
|
1478
|
+
mkdir -p $MU_CHEF_CACHE
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
###############################################################################
|
|
1483
|
+
## Get ~/.devops arranged
|
|
1484
|
+
install_mu_executables()
|
|
1485
|
+
{
|
|
1486
|
+
|
|
1487
|
+
status_message "Installing/updating Mu executables"
|
|
1488
|
+
|
|
1489
|
+
# if [ "$_me" == "mu-self-update" ];then
|
|
1490
|
+
# XXX need to test this a different way
|
|
1491
|
+
# if [ "`diff $MU_LIBDIR/bin/$_me $MU_INSTALLDIR/bin/$_me`" != "" -o "`diff $MU_LIBDIR/install/mu_setup $MU_INSTALLDIR/bin/mu-configure`" != "" ];then
|
|
1492
|
+
# status_message "We're updating $_me, and $_me has changed." "Re-invoking as ${BOLD}$MU_LIBDIR/bin/$_me $@${NORM}"
|
|
1493
|
+
# /bin/cp -f $MU_LIBDIR/bin/$_me $MU_INSTALLDIR/bin/$_me
|
|
1494
|
+
# /bin/cp -f $MU_LIBDIR/install/mu_setup $MU_INSTALLDIR/bin/mu-configure
|
|
1495
|
+
# chmod 0755 $MU_INSTALLDIR/bin/$_me $MU_INSTALLDIR/bin/mu-configure
|
|
1496
|
+
# exec $MU_LIBDIR/bin/$_me $1 $2 $3 $4 $5 $6 $7 $8 $9
|
|
1497
|
+
# exit
|
|
1498
|
+
# fi
|
|
1499
|
+
# fi
|
|
1500
|
+
|
|
1501
|
+
rm -rf $MU_INSTALLDIR/bin/*
|
|
1502
|
+
|
|
1503
|
+
# most executables should just be symlinks
|
|
1504
|
+
_files=$MU_LIBDIR/bin/*
|
|
1505
|
+
for file in $_files;do
|
|
1506
|
+
f="`basename $file`"
|
|
1507
|
+
if [ "$f" != "mu-self-update" ];then
|
|
1508
|
+
ln -s $MU_LIBDIR/bin/$f $MU_INSTALLDIR/bin/$f
|
|
1509
|
+
fi
|
|
1510
|
+
done
|
|
1511
|
+
|
|
1512
|
+
/bin/cp -f $MU_LIBDIR/bin/mu-self-update $MU_INSTALLDIR/bin/mu-self-update
|
|
1513
|
+
# /bin/cp -f $MU_LIBDIR/install/mu_setup $MU_INSTALLDIR/bin/mu-configure
|
|
1514
|
+
chmod 0755 $MU_INSTALLDIR/bin/mu-self-update $MU_INSTALLDIR/bin/mu-configure
|
|
1515
|
+
|
|
1516
|
+
# ...and make sure the flippin' link to mu-cli-lib.rb is right.
|
|
1517
|
+
/bin/rm -f $MU_INSTALLDIR/bin/mu-load-config.rb
|
|
1518
|
+
/bin/ln -s $MU_LIBDIR/modules/mu-load-config.rb $MU_INSTALLDIR/bin/mu-load-config.rb
|
|
1519
|
+
|
|
1520
|
+
chef_bin=/opt/chef/embedded/bin
|
|
1521
|
+
# We can get invoked before Chef is installed, so handle that gracefully
|
|
1522
|
+
if [ -d $chef_bin ];then
|
|
1523
|
+
for f in `ls -1 $chef_bin/*knife* $chef_bin/*chef* $chef_bin/*ohai*`;do
|
|
1524
|
+
name="`basename $f`"
|
|
1525
|
+
ln -s $f $MU_INSTALLDIR/bin/$name
|
|
1526
|
+
done
|
|
1527
|
+
fi
|
|
1528
|
+
|
|
1529
|
+
# Same thing, but for server-only executables
|
|
1530
|
+
chef_bin=/opt/opscode/embedded/bin
|
|
1531
|
+
if [ -d $chef_bin ];then
|
|
1532
|
+
for f in `ls -1 $chef_bin/*knife* $chef_bin/*chef* $chef_bin/*ohai*`;do
|
|
1533
|
+
name="`basename $f`"
|
|
1534
|
+
if [ ! -h $MU_INSTALLDIR/bin/$name ];then
|
|
1535
|
+
ln -s $f $MU_INSTALLDIR/bin/$name
|
|
1536
|
+
fi
|
|
1537
|
+
done
|
|
1538
|
+
fi
|
|
1539
|
+
chmod 755 $MU_INSTALLDIR/bin
|
|
1540
|
+
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
start_momma_cat()
|
|
1544
|
+
{
|
|
1545
|
+
status_message "Setting up ${BOLD}mu-momma-cat${NORM}"
|
|
1546
|
+
punch_tcp_hole 2260
|
|
1547
|
+
/bin/cp -f $MU_LIBDIR/bin/mu-momma-cat /etc/init.d/
|
|
1548
|
+
chkconfig mu-momma-cat on
|
|
1549
|
+
service mu-momma-cat restart
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
###############################################################################
|
|
1553
|
+
setup_localhost_chef_client()
|
|
1554
|
+
{
|
|
1555
|
+
punch_tcp_hole 7443 # sometimes this isn't ready
|
|
1556
|
+
allowuser="`grep ^AllowUsers /etc/ssh/sshd_config | awk '{print $2}'`"
|
|
1557
|
+
if [ "$allowuser" == "" ];then
|
|
1558
|
+
allowuser="root"
|
|
1559
|
+
fi
|
|
1560
|
+
if [ ! -f $HOMEDIR/.ssh/id_rsa.pub ];then
|
|
1561
|
+
ssh-keygen -N '' -f $HOMEDIR/.ssh/id_rsa
|
|
1562
|
+
chmod 600 $HOMEDIR/.ssh/id_rsa
|
|
1563
|
+
fi
|
|
1564
|
+
# On CentOS 7 and the like, this is some non-root user
|
|
1565
|
+
ssh_homedir="`getent passwd \"$allowuser\" |cut -d: -f6`"
|
|
1566
|
+
mkdir -p "$ssh_homedir/.ssh/"
|
|
1567
|
+
pubkey="`cat $HOMEDIR/.ssh/id_rsa.pub`"
|
|
1568
|
+
if [ "`grep \"$pubkey\" $ssh_homedir/.ssh/authorized_keys`" == "" ];then
|
|
1569
|
+
echo "$pubkey" >> $ssh_homedir/.ssh/authorized_keys
|
|
1570
|
+
fi
|
|
1571
|
+
chown -R "$allowuser" "$ssh_homedir/.ssh/"
|
|
1572
|
+
if [ "`grep '^Host localhost' $HOMEDIR/.ssh/config`" == "" ];then
|
|
1573
|
+
echo "Host localhost" >> $HOMEDIR/.ssh/config
|
|
1574
|
+
echo " IdentityFile $HOMEDIR/.ssh/id_rsa" >> $HOMEDIR/.ssh/config
|
|
1575
|
+
fi
|
|
1576
|
+
if [ "`/opt/chef/bin/knife node list | grep '^CAP-MASTER$'`" == "CAP-MASTER" ];then
|
|
1577
|
+
warning_message "Removing old Chef node profile 'CAP-MASTER'"
|
|
1578
|
+
rm -f /etc/chef/client.*
|
|
1579
|
+
/opt/chef/bin/knife node delete -y CAP-MASTER
|
|
1580
|
+
/opt/chef/bin/knife client delete -y CAP-MASTER
|
|
1581
|
+
fi
|
|
1582
|
+
if [ "`/opt/chef/bin/knife node list | grep '^MU-MASTER$'`" != "MU-MASTER" ];then
|
|
1583
|
+
status_message "Bootstrapping localhost as Chef node 'MU-MASTER'"
|
|
1584
|
+
chef_artifacts_uploaded=0
|
|
1585
|
+
if [ "$chef_artifacts_uploaded_by_installer" != "1" ];then
|
|
1586
|
+
upload_chef_artifacts -n -r $MU_REPO_NAME
|
|
1587
|
+
fi
|
|
1588
|
+
mkdir -p /etc/chef
|
|
1589
|
+
if [ "$allowuser" == "root" -o "$allowuser" == "" ];then
|
|
1590
|
+
/opt/chef/bin/knife bootstrap -N MU-MASTER --no-node-verify-api-cert --node-ssl-verify-mode=none ${CHEF_PUBLIC_IP}
|
|
1591
|
+
else
|
|
1592
|
+
/opt/chef/bin/knife bootstrap -N MU-MASTER --no-node-verify-api-cert --node-ssl-verify-mode=none -x ${allowuser} --sudo ${CHEF_PUBLIC_IP}
|
|
1593
|
+
fi
|
|
1594
|
+
run_chef_client=0
|
|
1595
|
+
fi
|
|
1596
|
+
|
|
1597
|
+
status_message "Configuring local LDAP directory"
|
|
1598
|
+
punch_tcp_hole 389
|
|
1599
|
+
punch_tcp_hole 636
|
|
1600
|
+
$MU_LIBDIR/install/ldap_setup.rb
|
|
1601
|
+
/opt/chef/bin/knife node run_list remove MU-MASTER "role[mu-master-jenkins]" > /dev/null 2>&1 # buggy prior invocations get fouled up on subsequent runs
|
|
1602
|
+
/opt/chef/bin/knife node run_list add MU-MASTER "role[mu-master]"
|
|
1603
|
+
chef_client
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
###############################################################################
|
|
1607
|
+
configure_nagios_server()
|
|
1608
|
+
{
|
|
1609
|
+
status_message "Configuring the ${BOLD}Nagios${NORM} server"
|
|
1610
|
+
punch_tcp_hole 8443
|
|
1611
|
+
if [ "`/bin/ls $MU_DATADIR/users/`" == "" ];then
|
|
1612
|
+
echo "${RED}Cannot enable Nagios until at least one admin user is specified.${NORM}"
|
|
1613
|
+
echo "${RED}Use ${BOLD}mu-user-manage${NORM}${RED} to create and manage users.${NORM}"
|
|
1614
|
+
return
|
|
1615
|
+
fi
|
|
1616
|
+
if [ "`grep ^nagios: /etc/passwd`" == "" -o "`pgrep -u nagios -f /usr/sbin/nagios`" == "" ];then
|
|
1617
|
+
# skip this if we're being called from mu-self-update and have already
|
|
1618
|
+
# done it
|
|
1619
|
+
if [ "$chef_artifacts_uploaded" != 1 ];then
|
|
1620
|
+
upload_chef_artifacts -r mu
|
|
1621
|
+
upload_chef_artifacts -n
|
|
1622
|
+
fi
|
|
1623
|
+
chef_client -o "recipe[mu-master::update_nagios_only]"
|
|
1624
|
+
run_chef_client=0
|
|
1625
|
+
fi
|
|
1626
|
+
mkdir -p /opt/mu/var/nagios_user_home
|
|
1627
|
+
chown nagios:nagios /opt/mu/var/nagios_user_home
|
|
1628
|
+
if [ "`grep ^nagios: /etc/passwd | grep /opt/mu/var/nagios_user_home`" = "" ];then
|
|
1629
|
+
/sbin/service nagios stop
|
|
1630
|
+
sleep 5
|
|
1631
|
+
/usr/bin/pkill -u nagios
|
|
1632
|
+
/usr/sbin/usermod -d /opt/mu/var/nagios_user_home nagios
|
|
1633
|
+
/sbin/service nagios start
|
|
1634
|
+
fi
|
|
1635
|
+
if [ -d /home/nagios ];then
|
|
1636
|
+
/bin/mv -f /home/nagios /home/nagios.old
|
|
1637
|
+
/bin/ln -s /opt/mu/var/nagios_user_home /home/nagios
|
|
1638
|
+
fi
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
###############################################################################
|
|
1642
|
+
preconfigure_jenkins_artifacts()
|
|
1643
|
+
{
|
|
1644
|
+
punch_tcp_hole 7443 # sometimes this isn't ready
|
|
1645
|
+
if [ "$JENKINS_ADMIN_PW" != "" ];then
|
|
1646
|
+
status_message "Configuring the ${BOLD}Jenkins${NORM} artifacts"
|
|
1647
|
+
punch_tcp_hole 9443
|
|
1648
|
+
if [ "`/bin/ls $MU_DATADIR/users/`" == "" ];then
|
|
1649
|
+
echo "${RED}Cannot enable Jenkins until at least one admin user is specified.${NORM}"
|
|
1650
|
+
echo "${RED}Use ${BOLD}mu-user-manage${NORM}${RED} to create and manage users.${NORM}"
|
|
1651
|
+
return
|
|
1652
|
+
fi
|
|
1653
|
+
# skip user and vault creation if we're being called from mu-self-update and have already
|
|
1654
|
+
# done it
|
|
1655
|
+
#
|
|
1656
|
+
if ! (knife vault show jenkins > /dev/null 2>&1) ;then
|
|
1657
|
+
# Create Jenkins Vault with admin and user items
|
|
1658
|
+
$MU_LIBDIR/install/jenkinskeys.rb
|
|
1659
|
+
knife vault create jenkins users "{\"mu_user_password\":\"$JENKINS_ADMIN_PW\"}" --mode client -F json -u mu --search name:MU-MASTER
|
|
1660
|
+
# Create the Jenkins user
|
|
1661
|
+
fi
|
|
1662
|
+
if [ ! -d /home/jenkins ];then
|
|
1663
|
+
$MU_LIBDIR/bin/mu-user-manage jenkins -e $JENKINS_ADMIN_EMAIL -p "$JENKINS_ADMIN_PW" -n "Jenkins Service" -s --no-scratchpad
|
|
1664
|
+
su - jenkins -c "ls"
|
|
1665
|
+
fi
|
|
1666
|
+
fi
|
|
1667
|
+
mkdir -p /home/jenkins
|
|
1668
|
+
chown jenkins /home/jenkins
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
|
|
1672
|
+
generate_docs()
|
|
1673
|
+
{
|
|
1674
|
+
status_message "Generating documentation"
|
|
1675
|
+
cd $MU_LIBDIR/modules && /usr/local/ruby-current/bin/bundle install
|
|
1676
|
+
/usr/local/ruby-current/bin/ruby $MU_INSTALLDIR/bin/mu-gen-docs
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
generate_ssl_certs()
|
|
1680
|
+
{
|
|
1681
|
+
status_message "Managing internal SSL certificates"
|
|
1682
|
+
skip_chef="$1"
|
|
1683
|
+
mkdir -p $MU_DATADIR/ssl
|
|
1684
|
+
cd $MU_DATADIR/ssl
|
|
1685
|
+
if [ -f Mu_CA.pem ];then
|
|
1686
|
+
# Force us to clean up crusty old certs that we generated badly
|
|
1687
|
+
if ! ( /usr/bin/openssl x509 -in $MU_DATADIR/ssl/Mu_CA.pem -text -noout | grep "Subject: CN=$CHEF_PUBLIC_IP, OU=Mu Server $CHEF_PUBLIC_IP," > /dev/null );then
|
|
1688
|
+
/usr/bin/openssl x509 -in $MU_DATADIR/ssl/Mu_CA.pem -text -noout | grep "Subject: "
|
|
1689
|
+
status_message "Forcing regeneration of Mu's self-signed SSL certificate authority (didn't see ${BOLD}Subject: CN=$CHEF_PUBLIC_IP, OU=Mu Server $CHEF_PUBLIC_IP,${NORM})"
|
|
1690
|
+
/usr/bin/openssl x509 -in $MU_DATADIR/ssl/Mu_CA.pem -text -noout | grep "Subject: "
|
|
1691
|
+
/bin/rm -f Mu_CA.*
|
|
1692
|
+
fi
|
|
1693
|
+
fi
|
|
1694
|
+
regen_all=0
|
|
1695
|
+
if [ ! -f Mu_CA.pem ];then
|
|
1696
|
+
regen_all=1
|
|
1697
|
+
status_message "Creating internal-use SSL certificate authority"
|
|
1698
|
+
openssl genrsa -out Mu_CA.key 4096
|
|
1699
|
+
chmod 400 Mu_CA.key
|
|
1700
|
+
openssl req -subj "/CN=$CHEF_PUBLIC_IP/OU=Mu Server $CHEF_PUBLIC_IP/O=eGlobalTech/C=US" -x509 -new -nodes -key Mu_CA.key -days 1024 -out Mu_CA.pem -sha512
|
|
1701
|
+
/bin/cp -f Mu_CA.pem $MU_LIBDIR/cookbooks/mu-tools/files/default/Mu_CA.pem
|
|
1702
|
+
if [ "$skip_chef" == "" ];then
|
|
1703
|
+
chef_artifacts_uploaded=0
|
|
1704
|
+
upload_chef_artifacts -r $MU_REPO_NAME -n -s
|
|
1705
|
+
fi
|
|
1706
|
+
elif [ ! -f $MU_LIBDIR/cookbooks/mu-tools/files/default/Mu_CA.pem ];then
|
|
1707
|
+
/bin/cp -f Mu_CA.pem $MU_LIBDIR/cookbooks/mu-tools/files/default/Mu_CA.pem
|
|
1708
|
+
if [ "$skip_chef" == "" ];then
|
|
1709
|
+
chef_artifacts_uploaded=0
|
|
1710
|
+
upload_chef_artifacts -r $MU_REPO_NAME -n -s
|
|
1711
|
+
fi
|
|
1712
|
+
fi
|
|
1713
|
+
|
|
1714
|
+
# XXX should use set_serial option and maniuplate "serial"
|
|
1715
|
+
for cert in rsyslog mommacat ldap;do
|
|
1716
|
+
if [ -f $cert.crt ];then
|
|
1717
|
+
# Force us to clean up crusty old certs that we generated badly,
|
|
1718
|
+
# making sure the CA cert is bundled while we're at it.
|
|
1719
|
+
if ! ( grep "BEGIN CERTIFICATE" $MU_DATADIR/ssl/$cert.crt | wc -l | grep '^2$' > /dev/null );then
|
|
1720
|
+
status_message "Forcing regeneration of $MU_DATADIR/ssl/$cert.crt"
|
|
1721
|
+
/bin/rm -f $cert.crt
|
|
1722
|
+
elif openssl x509 -text -noout -in $MU_DATADIR/ssl/$cert.crt | grep "Signature Algorithm: sha1WithRSAEncryption" > /dev/null ;then
|
|
1723
|
+
status_message "Forcing regeneration of $MU_DATADIR/ssl/$cert.crt (SHA-1 signature detected)"
|
|
1724
|
+
/bin/rm -f $cert.crt
|
|
1725
|
+
fi
|
|
1726
|
+
fi
|
|
1727
|
+
if [ ! -f $cert.crt -o $regen_all == 1 ];then
|
|
1728
|
+
status_message "Creating self-signed $cert SSL certificate"
|
|
1729
|
+
openssl genrsa -out $cert.key 4096
|
|
1730
|
+
chmod 400 $cert.key
|
|
1731
|
+
openssl req -subj "/CN=$CHEF_PUBLIC_IP/OU=Mu $cert/O=eGlobalTech/C=US" -new -key $cert.key -out $cert.csr -sha512
|
|
1732
|
+
openssl x509 -req -in $cert.csr -CA Mu_CA.pem -CAkey Mu_CA.key -CAcreateserial -out $cert.crt -days 500 -sha512
|
|
1733
|
+
cat Mu_CA.pem >> $cert.crt
|
|
1734
|
+
if [ "$cert" == "mommacat" -a "$skip_chef" == "" ];then
|
|
1735
|
+
chef_server_ctl restart
|
|
1736
|
+
/bin/rm -f /etc/chef/trusted_certs/*.crt /root/.chef/trusted_certs/*.crt
|
|
1737
|
+
/opt/chef/bin/knife ssl fetch -s https://$CHEF_PUBLIC_IP > /dev/null 2>&1
|
|
1738
|
+
/bin/cp -f /root/.chef/trusted_certs/*.crt /etc/chef/trusted_certs/
|
|
1739
|
+
if (knife ssl check -c /etc/chef/client.rb | egrep "^ERROR.*certificate");then
|
|
1740
|
+
/opt/chef/bin/knife ssl fetch -c /etc/chef/client.rb
|
|
1741
|
+
fi
|
|
1742
|
+
if (knife ssl check | egrep "^ERROR.*certificate");then
|
|
1743
|
+
/opt/chef/bin/knife ssl fetch
|
|
1744
|
+
fi
|
|
1745
|
+
fi
|
|
1746
|
+
fi
|
|
1747
|
+
if [ ! -f $cert.p12 -o $regen_all == 1 ];then
|
|
1748
|
+
openssl pkcs12 -export -inkey $cert.key -in $cert.crt -out $cert.p12 -nodes -name "$cert" -passout pass:""
|
|
1749
|
+
fi
|
|
1750
|
+
done
|
|
1751
|
+
/bin/cp -f /opt/mu/var/ssl/Mu_CA.pem /etc/pki/ca-trust/source/anchors/
|
|
1752
|
+
/usr/bin/update-ca-trust force-enable
|
|
1753
|
+
/usr/bin/update-ca-trust extract
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
enable_audit_logs()
|
|
1757
|
+
{
|
|
1758
|
+
status_message "Enabling Mu audit logs"
|
|
1759
|
+
punch_tcp_hole 10514
|
|
1760
|
+
set -e
|
|
1761
|
+
$MU_LIBDIR/bin/mu-aws-setup -l
|
|
1762
|
+
set +e
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
set_permissions()
|
|
1766
|
+
{
|
|
1767
|
+
/bin/chmod g+rsx "$MU_DATADIR/users"
|
|
1768
|
+
/bin/chgrp mu-users "$MU_DATADIR/users"
|
|
1769
|
+
cp -a $MU_LIBDIR/extras/git-fix-permissions-hook $MU_LIBDIR/.git/hooks/post-merge
|
|
1770
|
+
cp -a $MU_LIBDIR/extras/git-fix-permissions-hook $MU_LIBDIR/.git/hooks/post-checkout
|
|
1771
|
+
cp -a $MU_LIBDIR/extras/git-fix-permissions-hook $MU_LIBDIR/.git/hooks/post-rewrite
|
|
1772
|
+
status_message "Setting permissions in Ruby installations and platform repos"
|
|
1773
|
+
test -f $MU_INSTALLDIR/etc/amazon_images.yaml && chmod 644 $MU_INSTALLDIR/etc/amazon_images.yaml
|
|
1774
|
+
chmod 644 $MU_INSTALLDIR/etc/mu.rc
|
|
1775
|
+
for extra in $ADDTL_CHEF_REPOS;do
|
|
1776
|
+
extra_repo_name="`echo $extra | sed 's/^.*\///' | cut -d. -f1`"
|
|
1777
|
+
fix_platform_repo_permissions "$MU_DATADIR/$extra_repo_name"
|
|
1778
|
+
done
|
|
1779
|
+
fix_platform_repo_permissions "$MU_LIBDIR"
|
|
1780
|
+
if [ "$1" != "skip_rubies" ] ;then
|
|
1781
|
+
/sbin/restorecon -r /home
|
|
1782
|
+
for rubydir in /opt/opscode/embedded /opt/chef/embedded `find /opt/rubies -maxdepth 1 -mindepth 1 -type d`;do
|
|
1783
|
+
find $rubydir/lib/ruby/gems -type f -exec chmod o+r {} \;
|
|
1784
|
+
find $rubydir/lib/ruby/gems -type d -exec chmod o+rx {} \;
|
|
1785
|
+
done
|
|
1786
|
+
fi
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
generate_repo_berksfile()
|
|
1790
|
+
{
|
|
1791
|
+
repodir=$1
|
|
1792
|
+
cd $repodir || return
|
|
1793
|
+
if [ ! -f "Berksfile" ];then
|
|
1794
|
+
warning_message "Generating a Berksfile in ${BOLD}$repodir${NORM}"
|
|
1795
|
+
cat > "$repodir/Berksfile" << EOF
|
|
1796
|
+
if !ENV.include? 'MU_DATADIR'
|
|
1797
|
+
if !ENV.include? 'MU_INSTALLDIR'
|
|
1798
|
+
raise "Can't find MU_DATADIR or MU_INSTALLDIR in my environment!"
|
|
1799
|
+
end
|
|
1800
|
+
|
|
1801
|
+
ENV['MU_DATADIR'] = "#{ENV['MU_INSTALLDIR']}/var"
|
|
1802
|
+
end
|
|
1803
|
+
instance_eval(File.read(File.expand_path("#{ENV['MU_INSTALLDIR']}/lib/Berksfile", __FILE__)))
|
|
1804
|
+
source "https://supermarket.getchef.com"
|
|
1805
|
+
EOF
|
|
1806
|
+
for d in cookbooks site_cookbooks;do
|
|
1807
|
+
if [ -d "$repodir/$d" ];then
|
|
1808
|
+
cd "$repodir/$d"
|
|
1809
|
+
for c in `ls -1`;do
|
|
1810
|
+
echo "cookbook '$c', path: '$repodir/$d/$c'" >> "$repodir/Berksfile"
|
|
1811
|
+
done
|
|
1812
|
+
fi
|
|
1813
|
+
done
|
|
1814
|
+
cd "$repodir" && berks install
|
|
1815
|
+
fi
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
###############################################################################
|
|
1819
|
+
###############################################################################
|
|
1820
|
+
###############################################################################
|
|
1821
|
+
# Main execution path begins here
|
|
1822
|
+
###############################################################################
|
|
1823
|
+
###############################################################################
|
|
1824
|
+
###############################################################################
|
|
1825
|
+
|
|
1826
|
+
|
|
1827
|
+
if [ "$library" != "1" ];then
|
|
1828
|
+
if [ "$use_defaults" == "" ];then
|
|
1829
|
+
adjust_config_vars
|
|
1830
|
+
fi
|
|
1831
|
+
set_path_env_vars
|
|
1832
|
+
set_bash_defaults
|
|
1833
|
+
set_hostname
|
|
1834
|
+
set_logbucket
|
|
1835
|
+
create_ssh_config
|
|
1836
|
+
umask 0022
|
|
1837
|
+
clone_mu_repository
|
|
1838
|
+
for extra in $ADDTL_CHEF_REPOS;do
|
|
1839
|
+
extra_repo_name="`echo $extra | sed 's/^.*\///' | cut -d. -f1`"
|
|
1840
|
+
clone_repository "$extra" "$MU_DATADIR/$extra_repo_name"
|
|
1841
|
+
generate_repo_berksfile "$MU_DATADIR/$extra_repo_name"
|
|
1842
|
+
done
|
|
1843
|
+
if [ "$USER" == "root" ];then
|
|
1844
|
+
install_system_packages
|
|
1845
|
+
install_ruby
|
|
1846
|
+
install_awscli
|
|
1847
|
+
fi
|
|
1848
|
+
install_mu_executables
|
|
1849
|
+
# We might disconnect right here! That's normal.
|
|
1850
|
+
associate_public_ip
|
|
1851
|
+
create_private_dns_zone
|
|
1852
|
+
configure_ec2_security_group
|
|
1853
|
+
generate_ssl_certs skip_chef
|
|
1854
|
+
install_chef
|
|
1855
|
+
patch_knife_windows
|
|
1856
|
+
if [ "$USER" == "root" ];then
|
|
1857
|
+
# set up executables again to enable Chef aliases
|
|
1858
|
+
install_mu_executables
|
|
1859
|
+
enable_audit_logs
|
|
1860
|
+
umask 0077
|
|
1861
|
+
start_momma_cat
|
|
1862
|
+
setup_localhost_chef_client
|
|
1863
|
+
generate_ssl_certs
|
|
1864
|
+
configure_nagios_server
|
|
1865
|
+
set_permissions
|
|
1866
|
+
preconfigure_jenkins_artifacts
|
|
1867
|
+
fi
|
|
1868
|
+
if [ "$JENKINS_ADMIN_PW" != "" ];then
|
|
1869
|
+
punch_tcp_hole 7443 # sometimes this isn't ready
|
|
1870
|
+
knife node run_list add MU-MASTER "role[mu-master-jenkins]"
|
|
1871
|
+
chef_client -l info
|
|
1872
|
+
fi
|
|
1873
|
+
cd
|
|
1874
|
+
source $MURC
|
|
1875
|
+
generate_docs
|
|
1876
|
+
|
|
1877
|
+
# Chef's reloads of sshd don't seem to cause it to re-read its config for
|
|
1878
|
+
# some reason. This means regular user logins don't work on new installs
|
|
1879
|
+
# until it's been kicked.
|
|
1880
|
+
/sbin/service sshd restart
|
|
1881
|
+
|
|
1882
|
+
echo ""
|
|
1883
|
+
echo "You MUST source all of the changes I made to your environment:"
|
|
1884
|
+
echo ""
|
|
1885
|
+
echo "${BOLD}source $MURC${NORM}"
|
|
1886
|
+
echo ""
|
|
1887
|
+
$MU_LIBDIR/bin/mu-user-manage
|
|
1888
|
+
echo ""
|
|
1889
|
+
echo "To add more users, use ${BOLD}mu-user-manage${NORM}."
|
|
1890
|
+
echo ""
|
|
1891
|
+
fi
|