OSDN Git Service

Initial release of concourse-ci concourse-ci-0.1.0
authorwhitestar <whitestar@gaea.test>
Sat, 11 Feb 2017 01:42:35 +0000 (10:42 +0900)
committerwhitestar <whitestar@gaea.test>
Sat, 11 Feb 2017 01:42:35 +0000 (10:42 +0900)
15 files changed:
cookbooks/concourse-ci/.foodcritic [new file with mode: 0644]
cookbooks/concourse-ci/.rubocop.yml [new file with mode: 0644]
cookbooks/concourse-ci/CHANGELOG.md [new file with mode: 0644]
cookbooks/concourse-ci/Gemfile [new file with mode: 0644]
cookbooks/concourse-ci/README.md [new file with mode: 0644]
cookbooks/concourse-ci/Rakefile [new file with mode: 0644]
cookbooks/concourse-ci/attributes/default.rb [new file with mode: 0644]
cookbooks/concourse-ci/metadata.rb [new file with mode: 0644]
cookbooks/concourse-ci/recipes/default.rb [new file with mode: 0644]
cookbooks/concourse-ci/recipes/docker-compose.rb [new file with mode: 0644]
cookbooks/concourse-ci/spec/recipes/default_spec.rb [new file with mode: 0644]
cookbooks/concourse-ci/spec/spec_helper.rb [new file with mode: 0644]
cookbooks/concourse-ci/templates/default/opt/docker-compose/app/concourse/docker-compose.yml [new file with mode: 0644]
nodes/local-concourse.json [new file with mode: 0644]
roles/concourse.rb [new file with mode: 0644]

diff --git a/cookbooks/concourse-ci/.foodcritic b/cookbooks/concourse-ci/.foodcritic
new file mode 100644 (file)
index 0000000..f83b06c
--- /dev/null
@@ -0,0 +1,2 @@
+~FC001
+~FC019
diff --git a/cookbooks/concourse-ci/.rubocop.yml b/cookbooks/concourse-ci/.rubocop.yml
new file mode 100644 (file)
index 0000000..4e84d82
--- /dev/null
@@ -0,0 +1,47 @@
+AllCops:
+  Exclude:
+    - vendor/**/*
+
+AlignParameters:
+  Enabled: false
+LineLength:
+  Enabled: false
+Lint/UnusedBlockArgument:
+  Enabled: false
+Metrics/AbcSize:
+  Enabled: false
+Style/BlockComments:
+  Enabled: false
+Style/BlockDelimiters:
+  Enabled: false
+Style/ExtraSpacing:
+  Enabled: false
+Style/FileName:
+  Enabled: false
+Style/LeadingCommentSpace:
+  Enabled: false
+Style/RescueModifier:
+  Enabled: false
+Style/SpaceBeforeFirstArg:
+  Enabled: false
+Style/TrailingCommaInLiteral:
+  EnforcedStyleForMultiline: comma
+Style/WordArray:
+  Enabled: false
+
+#Lint/ShadowingOuterLocalVariable:
+#  Enabled: false
+#Metrics/MethodLength:
+#  Max: 10
+#Metrics/ModuleLength:
+#  Max: 100
+#Metrics/CyclomaticComplexity:
+#  Max: 6
+#Metrics/PerceivedComplexity:
+#  Max: 7
+#Style/AccessorMethodName:
+#  Enabled: false
+#Style/MultilineOperationIndentation:
+#  Enabled: false
+#Style/PerlBackrefs:
+#  Enabled: false
diff --git a/cookbooks/concourse-ci/CHANGELOG.md b/cookbooks/concourse-ci/CHANGELOG.md
new file mode 100644 (file)
index 0000000..2701beb
--- /dev/null
@@ -0,0 +1,6 @@
+concourse-ci CHANGELOG
+======================
+
+0.1.0
+-----
+- Initial release of concourse-ci
diff --git a/cookbooks/concourse-ci/Gemfile b/cookbooks/concourse-ci/Gemfile
new file mode 100644 (file)
index 0000000..907b097
--- /dev/null
@@ -0,0 +1,3 @@
+source 'https://rubygems.org'
+
+#gem 'foodcritic'
diff --git a/cookbooks/concourse-ci/README.md b/cookbooks/concourse-ci/README.md
new file mode 100644 (file)
index 0000000..9aecbe5
--- /dev/null
@@ -0,0 +1,113 @@
+concourse-ci Cookbook
+=====================
+
+This cookbook sets up a Concourse CI service by Docker Compose.
+
+## Contents
+
+- [Requirements](#requirements)
+    - [platforms](#platforms)
+    - [packages](#packages)
+    - [cookbooks](#cookbooks)
+- [Attributes](#attributes)
+- [Usage](#usage)
+    - [Recipes](#recipes)
+        - [concourse-ci::default](#concourse-cidefault)
+        - [concourse-ci::docker-compose](#concourse-cidocker-compose)
+    - [Role Examples](#role-examples)
+- [License and Authors](#license-and-authors)
+
+## Requirements
+
+### platforms
+- none.
+
+### packages
+- none.
+
+### cookbooks
+- `docker-grid`
+- `ssl_cert`
+
+## Attributes
+
+|Key|Type|Description, example|Default|
+|:--|:--|:--|:--|
+|`['concourse-ci']['docker-compose']['app_dir']`|String||`"#{node['docker-grid']['compose']['app_dir']}/concourse"`|
+|`['concourse-ci']['docker-compose']['pgdata_dir']`|String|Path string or nil (unset).|`"#{node['concourse-ci']['docker-compose']['app_dir']}/database"`|
+|`['concourse-ci']['docker-compose']['web_keys_dir']`|String|Path string.|`"#{node['concourse-ci']['docker-compose']['app_dir']}/keys/web"`|
+|`['concourse-ci']['docker-compose']['worker_keys_dir']`|String|Path string.|`"#{node['concourse-ci']['docker-compose']['app_dir']}/keys/worker"`|
+|`['concourse-ci']['docker-compose']['pgdata_dir']`|String|Path string or nil (unset).|`"#{node['concourse-ci']['docker-compose']['app_dir']}/database"`|
+|`['concourse-ci']['docker-compose']['config_format_version']`|String|Read only. `docker-compose.yml` format version. Only version 1 is supported now.|`'1'`|
+|`['concourse-ci']['docker-compose']['config']`|Hash|`docker-compose.yml` configurations.|See `attributes/default.rb`|
+
+## Usage
+
+### Recipes
+
+#### concourse-ci::default
+
+This recipe does nothing.
+
+#### concourse-ci::docker-compose
+
+This recipe generates SSH keys of each node and a `docker-compose.yml` file for the Concourse CI service.
+
+### Role Examples
+
+- `roles/concourse.rb`
+
+```ruby
+name 'concourse'
+description 'Concourse'
+
+run_list(
+  'role[docker]',
+  'recipe[concourse-ci::docker-compose]',
+)
+
+image = 'concourse/concourse:2.6.0'
+port = '18080'
+
+override_attributes(
+  'concourse-ci' => {
+    'docker-compose' => {
+      'config' => {
+        # Version 1 docker-compose format
+        'concourse-web' => {
+          'image' => image,
+          'ports' => [
+            "#{port}:8080",
+          ],
+          'environment' => {
+            'CONCOURSE_EXTERNAL_URL' => "http://192.168.1.3:#{port}",
+          },
+        },
+        'concourse-worker' => {
+          'image' => image,
+        },
+      },
+    },
+  },
+)
+```
+
+## License and Authors
+
+- Author:: whitestar at osdn.jp
+
+```text
+Copyright 2017, whitestar
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
diff --git a/cookbooks/concourse-ci/Rakefile b/cookbooks/concourse-ci/Rakefile
new file mode 100644 (file)
index 0000000..513cecc
--- /dev/null
@@ -0,0 +1,23 @@
+require 'rspec/core/rake_task'
+require 'rubocop/rake_task'
+require 'foodcritic'
+
+namespace :style do
+  desc 'Run Ruby style checks'
+  RuboCop::RakeTask.new(:ruby)
+
+  desc 'Run Chef style checks'
+  FoodCritic::Rake::LintTask.new(:chef) do |t|
+    t.options = {
+      fail_tags: ['any'],
+    }
+  end
+end
+
+desc 'Run all style checks'
+task style: ['style:chef', 'style:ruby']
+
+desc 'Run ChefSpec examples'
+RSpec::Core::RakeTask.new(:spec)
+
+task default: ['style', 'spec']
diff --git a/cookbooks/concourse-ci/attributes/default.rb b/cookbooks/concourse-ci/attributes/default.rb
new file mode 100644 (file)
index 0000000..864bb09
--- /dev/null
@@ -0,0 +1,148 @@
+#
+# Cookbook Name:: concourse-ci
+# Attributes:: default
+#
+# Copyright 2017, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# TODO: support with_ssl_cert_cookbook
+force_override['concourse-ci']['with_ssl_cert_cookbook'] = false
+# If ['concourse-ci']['with_ssl_cert_cookbook'] is true,
+# node['concourse-ci']['docker-compose']['config']
+# are overridden by the following 'common_name' attributes.
+default['concourse-ci']['ssl_cert']['common_name'] = node['fqdn']
+default['concourse-ci']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/concourse"
+default['concourse-ci']['docker-compose']['pgdata_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/database"
+default['concourse-ci']['docker-compose']['web_keys_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/keys/web"
+default['concourse-ci']['docker-compose']['worker_keys_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/keys/worker"
+
+# TODO: support version 2 format, and use `default` instead of `force_override`
+force_override['concourse-ci']['docker-compose']['config_format_version'] = '1'
+version_1_config = {
+  'concourse-db' => {
+    'restart' => 'always',
+    'image' => 'postgres:9.5',
+    'volumes' => [
+      #"#{node['concourse-ci']['docker-compose']['pgdata_dir']}:/database",
+    ],
+    'environment' => {
+      'POSTGRES_DB' => 'concourse',
+      'POSTGRES_USER' => 'concourse',
+      'POSTGRES_PASSWORD' => nil,
+      'PGDATA' => '/database',
+    },
+  },
+  'concourse-web' => {
+    'restart' => 'always',
+    'image' => 'concourse/concourse',  # latest, 2.6.0,...
+    'links' => [
+      'concourse-db',
+    ],
+    'command' => 'web',
+    'ports' => [
+      #'8080:8080',  # If you sepecify no value, Chef will sets '8080:8080'.
+    ],
+    'volumes' => [
+      "#{node['concourse-ci']['docker-compose']['web_keys_dir']}:/concourse-keys",
+    ],
+    'environment' => {
+      'CONCOURSE_BASIC_AUTH_USERNAME' => 'concourse',
+      'CONCOURSE_BASIC_AUTH_PASSWORD' => nil,
+      # If you sepecify no value, Chef will sets "http://#{node['ipaddress']}:8080".
+      'CONCOURSE_EXTERNAL_URL' => nil,
+      # `<POSTGRES_PASSWORD>` is a placeholder of password string.
+      'CONCOURSE_POSTGRES_DATA_SOURCE' => \
+        'postgres://concourse:<POSTGRES_PASSWORD>@concourse-db:5432/concourse?sslmode=disable',
+    },
+  },
+  'concourse-worker' => {
+    'restart' => 'always',
+    'image' => 'concourse/concourse',
+    'privileged' => true,
+    'links' => [
+      'concourse-web',
+    ],
+    'command' => 'worker',
+    'volumes' => [
+      "#{node['concourse-ci']['docker-compose']['worker_keys_dir']}:/concourse-keys",
+    ],
+    'environment' => {
+      'CONCOURSE_TSA_HOST' => 'concourse-web',
+    },
+  },
+}
+
+# Not supported yet.
+new_config = Marshal.load(Marshal.dump(version_1_config))  # deep copy
+new_config['concourse-web'].delete('links')
+new_config['concourse-worker'].delete('links')
+version_2_config = {
+  # Version 2 docker-compose format
+  'version' => '2',
+  'services' => new_config,
+}
+=begin
+version_2_config = {
+  # Version 2 docker-compose format
+  'version' => '2',
+  'services' => {
+    'concourse-db' => {
+      'restart' => 'always',
+      'image' => 'postgres:9.5',
+      'volumes' => [
+        #"#{node['concourse-ci']['docker-compose']['pgdata_dir']}:/database",
+      ],
+      'environment' => {
+        'POSTGRES_DB' => 'concourse',
+        'POSTGRES_USER' => 'concourse',
+        'POSTGRES_PASSWORD' => nil,
+        'PGDATA' => '/database',
+      },
+    },
+    'concourse-web' => {
+      'restart' => 'always',
+      'image' => 'concourse/concourse',  # latest, 2.6.0,...
+      'command' => 'web',
+      'ports' => [
+        #'8080:8080',
+      ],
+      'volumes' => [
+        "#{node['concourse-ci']['docker-compose']['web_keys_dir']}:/concourse-keys",
+      ],
+      'environment' => {
+        'CONCOURSE_BASIC_AUTH_USERNAME' => 'concourse',
+        'CONCOURSE_BASIC_AUTH_PASSWORD' => nil,
+        'CONCOURSE_EXTERNAL_URL' => nil,
+        'CONCOURSE_POSTGRES_DATA_SOURCE' => \
+          'postgres://concourse:<POSTGRES_PASSWORD>@concourse-db:5432/concourse?sslmode=disable',
+      },
+    },
+    'concourse-worker' => {
+      'restart' => 'always',
+      'image' => 'concourse/concourse',
+      'privileged' => true,
+      'command' => 'worker',
+      'volumes' => [
+        "#{node['concourse-ci']['docker-compose']['worker_keys_dir']}:/concourse-keys",
+      ],
+      'environment' => {
+        'CONCOURSE_TSA_HOST' => 'concourse-web',
+      },
+    },
+  },
+}
+=end
+default['concourse-ci']['docker-compose']['config'] = \
+  node['concourse-ci']['docker-compose']['config_format_version'] == '1' ? version_1_config : version_2_config
diff --git a/cookbooks/concourse-ci/metadata.rb b/cookbooks/concourse-ci/metadata.rb
new file mode 100644 (file)
index 0000000..0d330ae
--- /dev/null
@@ -0,0 +1,13 @@
+# $ knife supermarket share concourse-ci "Applications"
+name             'concourse-ci'
+maintainer       'whitestar'
+maintainer_email ''
+license          'Apache 2.0'
+description      'Installs/Configures Concourse CI by Docker Compose'
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version          '0.1.0'
+source_url       'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
+issues_url       'https://osdn.jp/projects/metasearch/ticket'
+
+depends 'docker-grid', '>= 0.2.7'
+depends 'ssl_cert', '>= 0.3.3'
diff --git a/cookbooks/concourse-ci/recipes/default.rb b/cookbooks/concourse-ci/recipes/default.rb
new file mode 100644 (file)
index 0000000..326968c
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# Cookbook Name:: concourse-ci
+# Recipe:: default
+#
+# Copyright 2017, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
diff --git a/cookbooks/concourse-ci/recipes/docker-compose.rb b/cookbooks/concourse-ci/recipes/docker-compose.rb
new file mode 100644 (file)
index 0000000..52929cd
--- /dev/null
@@ -0,0 +1,148 @@
+#
+# Cookbook Name:: concourse-ci
+# Recipe:: docker-compose
+#
+# Copyright 2017, whitestar
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'securerandom'
+
+doc_url = 'https://concourse.ci/docker-repository.html'
+
+include_recipe 'docker-grid::compose'
+
+app_dir = node['concourse-ci']['docker-compose']['app_dir']
+pgdata_dir = node['concourse-ci']['docker-compose']['pgdata_dir']
+web_keys_dir = node['concourse-ci']['docker-compose']['web_keys_dir']
+worker_keys_dir = node['concourse-ci']['docker-compose']['worker_keys_dir']
+#certs_dir = "#{app_dir}/certs"
+
+[
+  app_dir,
+  pgdata_dir,
+  web_keys_dir,
+  worker_keys_dir,
+  #certs_dir,
+].each {|dir|
+  resources(directory: dir) rescue directory dir do
+    owner 'root'
+    group 'root'
+    mode '0755'
+    recursive true
+  end if !dir.nil? && !dir.empty?
+}
+
+bash 'ssh-keygen_keys' do
+  code <<-"EOH"
+  script commands
+    ssh-keygen -t rsa -f #{web_keys_dir}/tsa_host_key -N ''
+    ssh-keygen -t rsa -f #{web_keys_dir}/session_signing_key -N ''
+    ssh-keygen -t rsa -f #{worker_keys_dir}/worker_key -N ''
+    cp #{worker_keys_dir}/worker_key.pub #{web_keys_dir}/authorized_worker_keys
+    cp #{web_keys_dir}/tsa_host_key.pub #{worker_keys_dir}
+  EOH
+  action :run
+  not_if { File.exist?("#{web_keys_dir}/tsa_host_key") }
+  not_if { File.exist?("#{web_keys_dir}/session_signing_key") }
+  not_if { File.exist?("#{worker_keys_dir}/worker_key") }
+end
+
+config_format_version = node['concourse-ci']['docker-compose']['config_format_version']
+
+# if config_format_version == '1'
+config_srvs = node['concourse-ci']['docker-compose']['config']
+override_config_srvs = node.override['concourse-ci']['docker-compose']['config']
+force_override_config_srvs = node.force_override['concourse-ci']['docker-compose']['config']
+if config_format_version == '2'
+  config_srvs = config_srvs['services']
+  override_config_srvs = override_config_srvs['services']
+  force_override_config_srvs = force_override_config_srvs['services']
+end
+
+# Database
+db_envs_org = config_srvs['concourse-db']['environment']
+db_envs = {}
+db_vols = []
+
+db_passwd = db_envs_org['POSTGRES_PASSWORD']
+if db_passwd.nil? || db_passwd.empty?
+  db_passwd = SecureRandom.hex  # or urlsafe_base64
+  db_envs['POSTGRES_PASSWORD'] = db_passwd
+end
+
+db_vols.push("#{pgdata_dir}:#{db_envs_org['PGDATA']}") if !pgdata_dir.nil? && !pgdata_dir.empty?
+
+force_override_config_srvs['concourse-db']['environment'] = db_envs unless db_envs.empty?
+override_config_srvs['concourse-db']['volumes'] = db_vols unless db_vols.empty?
+
+# Web
+web_envs_org = config_srvs['concourse-web']['environment']
+web_envs = {}
+
+web_ports = config_srvs['concourse-web']['ports']
+override_config_srvs['concourse-web']['ports'] = ['8080:8080'] if web_ports.empty?
+
+basic_auth_passwd = web_envs_org['CONCOURSE_BASIC_AUTH_PASSWORD']
+if basic_auth_passwd.nil? || basic_auth_passwd.empty?
+  basic_auth_passwd = SecureRandom.hex  # or urlsafe_base64
+  web_envs['CONCOURSE_BASIC_AUTH_PASSWORD'] = basic_auth_passwd
+end
+
+external_url = web_envs_org['CONCOURSE_EXTERNAL_URL']
+web_envs['CONCOURSE_EXTERNAL_URL'] = "http://#{node['ipaddress']}:8080" if external_url.nil?
+
+data_source = web_envs_org['CONCOURSE_POSTGRES_DATA_SOURCE']
+data_source.gsub!(/<POSTGRES_PASSWORD>/, db_passwd)
+web_envs['CONCOURSE_POSTGRES_DATA_SOURCE'] = data_source
+
+force_override_config_srvs['concourse-web']['environment'] = web_envs unless web_envs.empty?
+
+=begin
+if node['concourse-ci']['with_ssl_cert_cookbook']
+  ::Chef::Recipe.send(:include, SSLCert::Helper)
+  cn = node['concourse-ci']['ssl_cert']['common_name']
+  key_path = server_key_path(cn)
+
+  bash 'copy_ssl_server_key' do
+    code <<-EOH
+      cp #{key_path} #{certs_dir}/server.key
+      chmod 600 #{certs_dir}/server.key
+    EOH
+    sensitive true
+    action :nothing
+    subscribes :run, "file[#{key_path}]"
+  end
+
+  # TODO: key path setup.
+end
+=end
+
+template "#{app_dir}/docker-compose.yml" do
+  source  'opt/docker-compose/app/concourse/docker-compose.yml'
+  owner 'root'
+  group 'root'
+  mode '0600'
+  sensitive true
+end
+
+log <<-"EOM"
+Note: You must execute the following command manually.
+  See #{doc_url}
+  - Start:
+    $ cd #{app_dir}
+    $ sudo docker-compose up -d
+  - Stop
+    $ sudo docker-compose down
+EOM
diff --git a/cookbooks/concourse-ci/spec/recipes/default_spec.rb b/cookbooks/concourse-ci/spec/recipes/default_spec.rb
new file mode 100644 (file)
index 0000000..e06e0be
--- /dev/null
@@ -0,0 +1,9 @@
+require_relative '../spec_helper'
+
+describe 'concourse-ci::default' do
+  let(:chef_run) { ChefSpec::SoloRunner.new.converge(described_recipe) }
+
+  #it 'does something' do
+  #  expect(chef_run).to do_something('...')
+  #end
+end
diff --git a/cookbooks/concourse-ci/spec/spec_helper.rb b/cookbooks/concourse-ci/spec/spec_helper.rb
new file mode 100644 (file)
index 0000000..1995e2b
--- /dev/null
@@ -0,0 +1,25 @@
+# Added by ChefSpec
+require 'chefspec'
+
+# Uncomment to use ChefSpec's Berkshelf extension
+# require 'chefspec/berkshelf'
+
+RSpec.configure do |config|
+  # Specify the path for Chef Solo to find cookbooks
+  # config.cookbook_path = '/var/cookbooks'
+
+  # Specify the path for Chef Solo to find roles
+  # config.role_path = '/var/roles'
+
+  # Specify the Chef log_level (default: :warn)
+  # config.log_level = :debug
+
+  # Specify the path to a local JSON file with Ohai data
+  # config.path = 'ohai.json'
+
+  # Specify the operating platform to mock Ohai data from
+  # config.platform = 'ubuntu'
+
+  # Specify the operating version to mock Ohai data from
+  # config.version = '12.04'
+end
diff --git a/cookbooks/concourse-ci/templates/default/opt/docker-compose/app/concourse/docker-compose.yml b/cookbooks/concourse-ci/templates/default/opt/docker-compose/app/concourse/docker-compose.yml
new file mode 100644 (file)
index 0000000..0e5de26
--- /dev/null
@@ -0,0 +1,7 @@
+<%
+config = node['concourse-ci']['docker-compose']['config']
+
+require 'yaml'
+yaml_str = config.to_hash.to_yaml
+-%>
+<%= yaml_str %>
diff --git a/nodes/local-concourse.json b/nodes/local-concourse.json
new file mode 100644 (file)
index 0000000..4ae8e61
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "run_list": [
+    "role[concourse]"
+  ]
+}
diff --git a/roles/concourse.rb b/roles/concourse.rb
new file mode 100644 (file)
index 0000000..38e714d
--- /dev/null
@@ -0,0 +1,49 @@
+name 'concourse'
+description 'Concourse'
+
+run_list(
+  #'recipe[ssl_cert::server_key_pairs]',
+  'role[docker]',
+  'recipe[concourse-ci::docker-compose]',
+)
+
+#env_run_lists()
+
+#default_attributes()
+
+image = 'concourse/concourse'  # of 'concourse/concourse:2.6.0',...
+port = '8080'
+concourse_cn = 'concourse.io.example.com'
+
+override_attributes(
+  'concourse-ci' => {
+    # Not supported yet.
+    'with_ssl_cert_cookbook' => false,
+    'ssl_cert' => {
+      'common_name' => concourse_cn,
+    },
+    'docker-compose' => {
+      'config' => {
+        # Version 1 docker-compose format
+        'concourse-web' => {
+          'image' => image,
+          'ports' => [
+            #"#{port}:8080",  # If you sepecify no value, Chef will sets '8080:8080'.
+          ],
+          'environment' => {
+            # If you sepecify no value, Chef will sets "http://#{node['ipaddress']}:8080".
+            #'CONCOURSE_EXTERNAL_URL' => "http://192.168.1.3:#{port}",
+          },
+        },
+        'concourse-worker' => {
+          'image' => image,
+        },
+      },
+    },
+  },
+  'ssl_cert' => {
+    'common_names' => [
+      concourse_cn,
+    ],
+  },
+)