Skip to content
Snippets Groups Projects
Commit 65e8b7e6 authored by Marin Jankovski's avatar Marin Jankovski
Browse files

Merge branch 'cpcp' into 'master'


First pass at CPCP changes

This adds the foodcritc rules and some rubocop rules to help standardize
building this cookbook. These are only suggestions, and you are more
then welcome to edit how you think you should.

This is only the start of the changes that'll be made for CPCP, but it
is at least a good start.

Signed-off-by: default avatarJJ Asghar <jj@chef.io>

See merge request !31
parents 5390cec2 23c4ea2f
No related branches found
No related tags found
1 merge request!31First pass at CPCP changes
source "https://api.berkshelf.com"
source 'https://api.berkshelf.com'
 
metadata
source 'https://rubygems.org'
 
gem 'berkshelf'
gem 'chef'
gem 'chefspec'
gem 'foodcritic'
gem 'rubocop'
gem 'test-kitchen'
gem 'cookstyle'
 
# Uncomment these lines if you want to live on the Edge:
#
Loading
Loading
@@ -13,4 +19,3 @@ gem 'berkshelf'
# gem "vagrant-berkshelf", github: "berkshelf/vagrant-berkshelf"
# gem "vagrant-omnibus", github: "schisamo/vagrant-omnibus"
# end
Loading
Loading
@@ -2,32 +2,32 @@
# vi: set ft=ruby :
 
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
VAGRANTFILE_API_VERSION = '2'.freeze
 
Vagrant.require_version ">= 1.5.0"
Vagrant.require_version '>= 1.5.0'
 
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
 
config.vm.hostname = "cookbook-omnibus-gitlab"
config.vm.hostname = 'cookbook-omnibus-gitlab'
 
# Set the version of chef to install using the vagrant-omnibus plugin
config.omnibus.chef_version = :latest
 
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "opscode_ubuntu-14.04_provisionerless"
config.vm.box = 'opscode_ubuntu-14.04_provisionerless'
 
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box"
config.vm.box_url = 'http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box'
 
# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
# network interface) by any external networks.
config.vm.network :private_network, type: "dhcp"
config.vm.network :private_network, type: 'dhcp'
 
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
Loading
Loading
@@ -55,7 +55,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# information on available options.
 
# The path to the Berksfile to use with Vagrant Berkshelf
config.berkshelf.berksfile_path = "./Berksfile"
config.berkshelf.berksfile_path = './Berksfile'
 
# Enabling the Berkshelf plugin. To enable this globally, add this configuration
# option to your ~/.vagrant.d/Vagrantfile file
Loading
Loading
@@ -69,7 +69,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# to skip installing and copying to Vagrant's shelf.
# config.berkshelf.except = []
 
config.vm.provision :shell, inline: "sudo apt-get update --fix-missing"
config.vm.provision :shell, inline: 'sudo apt-get update --fix-missing'
config.vm.provision :chef_solo do |chef|
chef.log_level = :debug
 
Loading
Loading
@@ -82,7 +82,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
}
 
chef.run_list = [
"recipe[omnibus-gitlab::default]"
'recipe[omnibus-gitlab::default]'
]
end
end
default['omnibus-gitlab']['package']['url'] = "https://downloads-packages.s3.amazonaws.com/ubuntu-12.04/gitlab_6.9.0-omnibus-1_amd64.deb"
default['omnibus-gitlab']['package']['sha256'] = "42e8224f8aa8689ba80380d036a3b367ffb63a85b5e447670a5233d888b85924"
default['omnibus-gitlab']['package']['url'] = 'https://downloads-packages.s3.amazonaws.com/ubuntu-12.04/gitlab_6.9.0-omnibus-1_amd64.deb'
default['omnibus-gitlab']['package']['sha256'] = '42e8224f8aa8689ba80380d036a3b367ffb63a85b5e447670a5233d888b85924'
default['omnibus-gitlab']['package']['repo'] = 'gitlab/gitlab-ce'
default['omnibus-gitlab']['package']['base_url'] = 'https://packages.gitlab.com'
default['omnibus-gitlab']['package']['name'] = 'gitlab-ce'
Loading
Loading
@@ -10,16 +10,16 @@ default['omnibus-gitlab']['data_bag'] = nil
 
default['omnibus-gitlab']['ssh']['host_keys'] = {} # hash of 'filename' => 'contents' pairs
 
default['omnibus-gitlab']['gitlab_rb']['nginx']['ssl_certificate'] = "/etc/gitlab/ssl/nginx.crt"
default['omnibus-gitlab']['gitlab_rb']['nginx']['ssl_certificate_key'] = "/etc/gitlab/ssl/nginx.key"
default['omnibus-gitlab']['gitlab_rb']['ci-nginx']['ssl_certificate'] = "/etc/gitlab/ssl/ci-nginx.crt"
default['omnibus-gitlab']['gitlab_rb']['ci-nginx']['ssl_certificate_key'] = "/etc/gitlab/ssl/ci-nginx.key"
default['omnibus-gitlab']['gitlab_rb']['mattermost-nginx']['ssl_certificate'] = "/etc/gitlab/ssl/mattermost-nginx.crt"
default['omnibus-gitlab']['gitlab_rb']['mattermost-nginx']['ssl_certificate_key'] = "/etc/gitlab/ssl/mattermost-nginx.key"
default['omnibus-gitlab']['gitlab_rb']['pages-nginx']['ssl_certificate'] = "/etc/gitlab/ssl/pages.crt"
default['omnibus-gitlab']['gitlab_rb']['pages-nginx']['ssl_certificate_key'] = "/etc/gitlab/ssl/pages.key"
default['omnibus-gitlab']['gitlab_rb']['registry-nginx']['ssl_certificate'] = "/etc/gitlab/ssl/registry.crt"
default['omnibus-gitlab']['gitlab_rb']['registry-nginx']['ssl_certificate_key'] = "/etc/gitlab/ssl/registry.key"
default['omnibus-gitlab']['gitlab_rb']['nginx']['ssl_certificate'] = '/etc/gitlab/ssl/nginx.crt'
default['omnibus-gitlab']['gitlab_rb']['nginx']['ssl_certificate_key'] = '/etc/gitlab/ssl/nginx.key'
default['omnibus-gitlab']['gitlab_rb']['ci-nginx']['ssl_certificate'] = '/etc/gitlab/ssl/ci-nginx.crt'
default['omnibus-gitlab']['gitlab_rb']['ci-nginx']['ssl_certificate_key'] = '/etc/gitlab/ssl/ci-nginx.key'
default['omnibus-gitlab']['gitlab_rb']['mattermost-nginx']['ssl_certificate'] = '/etc/gitlab/ssl/mattermost-nginx.crt'
default['omnibus-gitlab']['gitlab_rb']['mattermost-nginx']['ssl_certificate_key'] = '/etc/gitlab/ssl/mattermost-nginx.key'
default['omnibus-gitlab']['gitlab_rb']['pages-nginx']['ssl_certificate'] = '/etc/gitlab/ssl/pages.crt'
default['omnibus-gitlab']['gitlab_rb']['pages-nginx']['ssl_certificate_key'] = '/etc/gitlab/ssl/pages.key'
default['omnibus-gitlab']['gitlab_rb']['registry-nginx']['ssl_certificate'] = '/etc/gitlab/ssl/registry.crt'
default['omnibus-gitlab']['gitlab_rb']['registry-nginx']['ssl_certificate_key'] = '/etc/gitlab/ssl/registry.key'
 
default['omnibus-gitlab']['ssl']['certificate'] = ''
default['omnibus-gitlab']['ssl']['private_key'] = ''
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ module OmnibusGitlab
if data_bag_name && Chef::Search::Query.new.search(data_bag_name, "id:#{data_bag_item}").any?
Chef::EncryptedDataBagItem.load(data_bag_name, data_bag_item).to_hash
else
Hash.new
{}
end
end
 
Loading
Loading
@@ -26,7 +26,7 @@ module OmnibusGitlab
result = hash
 
path.each do |p|
result[p] ||= Hash.new
result[p] ||= {}
result = result[p]
end
 
Loading
Loading
Loading
Loading
@@ -5,6 +5,8 @@ license 'All rights reserved'
description 'Installs/Configures GitLab using omnibus-gitlab'
long_description 'Installs/Configures GitLab using omnibus-gitlab'
version '0.3.10'
issues_url 'https://gitlab.com/gitlab-org/cookbook-omnibus-gitlab/issues'
source_url 'https://gitlab.com/gitlab-org/cookbook-omnibus-gitlab/'
 
depends 'gitlab-vault'
depends 'apt'
Loading
Loading
@@ -25,9 +25,7 @@ if backup_cron_job['skip'].any?
options << " SKIP=#{backup_cron_job['skip'].join(',')}"
end
 
if backup_cron_job['silent']
options << " CRON=1"
end
options << ' CRON=1' if backup_cron_job['silent']
 
cron 'GitLab backup' do
command "/opt/gitlab/bin/gitlab-rake gitlab:backup:create #{options}"
Loading
Loading
Loading
Loading
@@ -8,10 +8,10 @@
#
 
attributes_with_secrets = if node['omnibus-gitlab']['data_bag']
OmnibusGitlab.fetch_from_databag(node, "omnibus-gitlab")
OmnibusGitlab.fetch_from_databag(node, 'omnibus-gitlab')
else
include_recipe 'gitlab-vault'
GitLab::Vault.get(node, "omnibus-gitlab")
GitLab::Vault.get(node, 'omnibus-gitlab')
end
 
pkg_base_url = node['omnibus-gitlab']['package']['base_url']
Loading
Loading
@@ -22,7 +22,7 @@ case node['platform_family']
when 'debian'
execute "add #{pkg_base_url}/#{pkg_repo} apt repo" do
command "curl #{pkg_base_url}/install/repositories/#{pkg_repo}/script.deb.sh | bash"
creates "/etc/apt/sources.list.d/#{pkg_repo.sub('/','_')}.list"
creates "/etc/apt/sources.list.d/#{pkg_repo.sub('/', '_')}.list"
end
 
package node['omnibus-gitlab']['package']['name'] do
Loading
Loading
@@ -35,7 +35,7 @@ when 'debian'
when 'rhel'
execute "add #{pkg_base_url}/#{pkg_repo} yum repo" do
command "curl #{pkg_base_url}/install/repositories/#{pkg_repo}/script.rpm.sh | bash"
creates "/etc/yum.repos.d/#{pkg_repo.sub('/','_')}.repo"
creates "/etc/yum.repos.d/#{pkg_repo.sub('/', '_')}.repo"
end
 
package node['omnibus-gitlab']['package']['name'] do
Loading
Loading
@@ -47,13 +47,13 @@ when 'rhel'
end
 
# Create /etc/gitlab and its contents
directory "/etc/gitlab"
directory '/etc/gitlab'
 
# Fetch encrypted secrets and node attributes
gitlab_rb = attributes_with_secrets["gitlab_rb"]
gitlab_rb = attributes_with_secrets['gitlab_rb']
 
template "/etc/gitlab/gitlab.rb" do
mode "0600"
template '/etc/gitlab/gitlab.rb' do
mode '0600'
variables(gitlab_rb: gitlab_rb)
helper(:single_quote) { |value| value.nil? ? nil : "'#{value}'" }
notifies :run, 'execute[gitlab-ctl reconfigure]'
Loading
Loading
@@ -67,12 +67,12 @@ file '/etc/gitlab/skip-auto-migrations' do
end
end
 
directory "/etc/gitlab/ssl" do
mode "0700"
directory '/etc/gitlab/ssl' do
mode '0700'
end
 
# Fetch encrypted secrets and node attributes
ssl = attributes_with_secrets["ssl"]
ssl = attributes_with_secrets['ssl']
 
file node['omnibus-gitlab']['gitlab_rb']['nginx']['ssl_certificate'] do
content ssl['certificate']
Loading
Loading
@@ -83,7 +83,7 @@ end
file node['omnibus-gitlab']['gitlab_rb']['nginx']['ssl_certificate_key'] do
content ssl['private_key']
not_if { ssl['private_key'].nil? }
mode "0600"
mode '0600'
notifies :run, 'bash[reload nginx configuration]'
end
 
Loading
Loading
@@ -96,7 +96,7 @@ end
file node['omnibus-gitlab']['gitlab_rb']['ci-nginx']['ssl_certificate_key'] do
content ssl['ci_private_key']
not_if { ssl['ci_private_key'].nil? }
mode "0600"
mode '0600'
notifies :run, 'bash[reload nginx configuration]'
end
 
Loading
Loading
@@ -109,7 +109,7 @@ end
file node['omnibus-gitlab']['gitlab_rb']['mattermost-nginx']['ssl_certificate_key'] do
content ssl['mattermost_private_key']
not_if { ssl['mattermost_private_key'].nil? }
mode "0600"
mode '0600'
notifies :run, 'bash[reload nginx configuration]'
end
 
Loading
Loading
@@ -138,12 +138,12 @@ file node['omnibus-gitlab']['gitlab_rb']['registry-nginx']['ssl_certificate_key'
end
 
# Run gitlab-ctl reconfigure if /etc/gitlab/gitlab.rb changed
execute "gitlab-ctl reconfigure" do
execute 'gitlab-ctl reconfigure' do
action :nothing
end
 
# Reload NGINX if the SSL certificate or key has changed
bash "reload nginx configuration" do
bash 'reload nginx configuration' do
code <<-EOS
if gitlab-ctl status nginx ; then
gitlab-ctl hup nginx
Loading
Loading
Loading
Loading
@@ -13,10 +13,10 @@
# All rights reserved - Do Not Redistribute
#
attributes_with_secrets = if node['omnibus-gitlab']['data_bag']
OmnibusGitlab.fetch_from_databag(node, "omnibus-gitlab")
OmnibusGitlab.fetch_from_databag(node, 'omnibus-gitlab')
else
include_recipe 'gitlab-vault'
GitLab::Vault.get(node, "omnibus-gitlab")
GitLab::Vault.get(node, 'omnibus-gitlab')
end
 
ssh = attributes_with_secrets['ssh']
Loading
Loading
@@ -28,7 +28,7 @@ ssh['host_keys'].each do |filename, key_material|
# private key. If this fails, the Chef run will fail and the target file is
# not overwritten.
bash "install SSH host key #{filename}" do
code %Q{
code %{
set -e
set -u
 
Loading
Loading
@@ -57,6 +57,6 @@ mv ${temp_key}.pub #{key_path}.pub
# then ssh-keygen will prompt the user for a password, effectively making
# the script hang.
timeout 10
not_if { File.exists?(key_path) && File.read(key_path).strip == key_material.strip }
not_if { File.exist?(key_path) && File.read(key_path).strip == key_material.strip }
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment