OSDN Git Service

adds the aptly recipe to the apt_utils cookbook. apt_utils-0.2.1
authorwhitestar <whitestar@users.osdn.me>
Sat, 15 Jul 2017 11:42:41 +0000 (20:42 +0900)
committerwhitestar <whitestar@users.osdn.me>
Sat, 15 Jul 2017 11:42:41 +0000 (20:42 +0900)
14 files changed:
cookbooks/apt_utils/.rubocop.yml
cookbooks/apt_utils/Berksfile
cookbooks/apt_utils/CHANGELOG.md
cookbooks/apt_utils/Gemfile [new file with mode: 0644]
cookbooks/apt_utils/README.md
cookbooks/apt_utils/Rakefile
cookbooks/apt_utils/attributes/default.rb
cookbooks/apt_utils/concourse.yml [new file with mode: 0644]
cookbooks/apt_utils/fly-vars.yml [new file with mode: 0644]
cookbooks/apt_utils/metadata.rb
cookbooks/apt_utils/recipes/aptly.rb [new file with mode: 0644]
cookbooks/apt_utils/templates/default/etc/apt/sources.list.d/aptly.list [new file with mode: 0644]
cookbooks/apt_utils/templates/default/etc/aptly.conf [new file with mode: 0644]
cookbooks/apt_utils/version [new file with mode: 0644]

index 17f87f1..12888b1 100644 (file)
@@ -10,6 +10,8 @@ Lint/UnusedBlockArgument:
   Enabled: false
 Metrics/AbcSize:
   Enabled: false
+Metrics/BlockLength:
+  Max: 50
 Style/BlockComments:
   Enabled: false
 Style/BlockDelimiters:
@@ -24,11 +26,15 @@ Style/RescueModifier:
   Enabled: false
 Style/SpaceBeforeFirstArg:
   Enabled: false
+Style/SpaceInsideBlockBraces:
+  Enabled: false
+Style/SpaceInsidePercentLiteralDelimiters:
+  Enabled: false
 Style/TrailingCommaInLiteral:
-  EnforcedStyleForMultiline: comma
+  EnforcedStyleForMultiline: consistent_comma
 Style/WordArray:
   Enabled: false
-  
+
 #Style/AccessorMethodName:
 #  Enabled: false
 #Style/MethodLength:
index 1b3958d..cf64fb9 100644 (file)
 # limitations under the License.
 #
 
-#grid_chef_repo = 'git://git.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
-
-# for ver. 3.x
-#source 'https://berks-api.io.example.com:6280'
 source 'https://supermarket.chef.io'
 
 metadata
index 15c373c..445325f 100644 (file)
@@ -1,6 +1,10 @@
 apt_utils CHANGELOG
 ===================
 
+0.2.1
+-----
+- adds the `apt_utils::aptly` recipe.
+
 0.2.0
 -----
 - adds the `apt_utils::apt` recipe.
diff --git a/cookbooks/apt_utils/Gemfile b/cookbooks/apt_utils/Gemfile
new file mode 100644 (file)
index 0000000..ad84be7
--- /dev/null
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# with Chef DK
+gem 'stove'
index e8983dd..55387c7 100644 (file)
@@ -6,16 +6,17 @@ This cookbook includes apt utility (apt-cacher-ng, apt mirroring site setup and
 ## Contents
 
 - [Requirements](#requirements)
-  - [packages](#packages)
+    - [packages](#packages)
 - [Attributes](#attributes)
-  - [apt_utils::default](#apt_utilsdefault)
+    - [apt_utils::default](#apt_utilsdefault)
 - [Usage](#usage)
-  - [Recipes](#recipes)
-    - [apt_utils::apt](#apt_utilsapt)
-    - [apt_utils::conf](#apt_utilsconf)
-    - [apt_utils::apt-cacher-ng](#apt_utilsapt-cacher-ng)
-    - [apt_utils::mirror](#apt_utilsmirror)
-    - [apt_utils::source](#apt_utilssource)
+    - [Recipes](#recipes)
+        - [apt_utils::apt](#apt_utilsapt)
+        - [apt_utils::aptly](#apt_utilsaptly)
+        - [apt_utils::conf](#apt_utilsconf)
+        - [apt_utils::apt-cacher-ng](#apt_utilsapt-cacher-ng)
+        - [apt_utils::mirror](#apt_utilsmirror)
+        - [apt_utils::source](#apt_utilssource)
 - [License and Authors](#license-and-authors)
 
 ## Requirements
@@ -35,6 +36,8 @@ This cookbook includes apt utility (apt-cacher-ng, apt mirroring site setup and
 |`['apt_utils']['conf']['proxy']['ftp']`|String|Proxy setting for FTP (ver. 0.1.1 or later)|`'nil'`|
 |`['apt_utils']['conf']['proxy']['http']`|String|Proxy setting for HTTP (ver. 0.1.1 or later)|`'nil'`|
 |`['apt_utils']['conf']['proxy']['https']`|String|Proxy setting for HTTPS (ver. 0.1.1 or later)|`'nil'`|
+|`['apt_utils']['aptly']['apt_repo']['keyserver']`|String||`'keys.gnupg.net'`|
+|`['apt_utils']['aptly']['apt_repo']['recv-keys']`|String||`'9E3E53F19C7DE460'`|
 |`['apt_utils']['apt-cacher-ng']['CacheDir']`|String|path to cache directory|`'/var/cache/apt-cacher-ng'`|
 |`['apt_utils']['apt-cacher-ng']['LogDir']`|String|path to log directory.|`'/var/log/apt-cacher-ng'`|
 |`['apt_utils']['apt-cacher-ng']['Port']`|String|service port number.|`'3142'`|
@@ -58,6 +61,10 @@ This cookbook includes apt utility (apt-cacher-ng, apt mirroring site setup and
 
 - includes `apt::default` recipe if the platform family is `debian`. 
 
+#### apt_utils::aptly
+
+- installs aptly
+
 #### apt_utils::conf
 
 - deploys apt configuration files to the `/etc/apt/apt.conf.d` directory.
index 513cecc..64191a5 100644 (file)
@@ -1,10 +1,15 @@
 require 'rspec/core/rake_task'
 require 'rubocop/rake_task'
 require 'foodcritic'
+require 'stove/rake_task'
 
 namespace :style do
   desc 'Run Ruby style checks'
-  RuboCop::RakeTask.new(:ruby)
+  RuboCop::RakeTask.new(:ruby) do |t|
+    t.options = [
+      '--auto-gen-config',  # creates .rubocop_todo.yml
+    ]
+  end
 
   desc 'Run Chef style checks'
   FoodCritic::Rake::LintTask.new(:chef) do |t|
@@ -20,4 +25,17 @@ task style: ['style:chef', 'style:ruby']
 desc 'Run ChefSpec examples'
 RSpec::Core::RakeTask.new(:spec)
 
+desc 'Publish cookbook'
+Stove::RakeTask.new(:publish) do |t|
+  t.stove_opts = [
+    # `--username` and `--key` are set in ~/.stove typically.
+    #'--username', 'somebody',
+    #'--key', '~/chef/chef.io.example.com/somebody.pem',
+    #'--endpoint', 'https://supermarket.io.example.com/api/v1',  # default: supermarket.chef.io
+    #'--no-ssl-verify',
+    '--no-git',
+    '--log-level', 'info',
+  ]
+end
+
 task default: ['style', 'spec']
index 2b03c5f..b6c359b 100644 (file)
@@ -38,6 +38,31 @@ default['apt_utils']['source']['apt_lines'] = [
   #'deb http://ftp.grid.example.com:3142/security.debian.org/ wheezy/updates main contrib non-free'
 ]
 
+default['apt_utils']['aptly']['apt_repo'] = {
+  'keyserver' => 'keys.gnupg.net',
+  'recv-keys' => '9E3E53F19C7DE460',
+}
+default['apt_utils']['aptly']['user'] = 'root'
+default['apt_utils']['aptly']['conf'] = {
+  # see https://www.aptly.info/doc/configuration/
+  'rootDir' => '/var/lib/aptly',
+  'downloadConcurrency' => 4,
+  'downloadSpeedLimit' => 0,
+  'architectures' => [],
+  'dependencyFollowSuggests' => false,
+  'dependencyFollowRecommends' => false,
+  'dependencyFollowAllVariants' => false,
+  'dependencyFollowSource' => false,
+  'gpgDisableSign' => false,
+  'gpgDisableVerify' => false,
+  'downloadSourcePackages' => false,
+  'ppaDistributorID' => 'ubuntu',
+  'ppaCodename' => '',
+  'skipContentsPublishing' => false,
+  'S3PublishEndpoints' => {},
+  'SwiftPublishEndpoints' => {},
+}
+
 default['apt_utils']['apt-cacher-ng']['CacheDir'] = '/var/cache/apt-cacher-ng'
 default['apt_utils']['apt-cacher-ng']['LogDir'] = '/var/log/apt-cacher-ng'
 default['apt_utils']['apt-cacher-ng']['SupportDir'] = '/usr/lib/apt-cacher-ng'
diff --git a/cookbooks/apt_utils/concourse.yml b/cookbooks/apt_utils/concourse.yml
new file mode 100644 (file)
index 0000000..9ffd782
--- /dev/null
@@ -0,0 +1,110 @@
+---
+# $ fly -t target sp -p apt_utils-cookbook -c concourse.yml -l fly-vars.yml -l ~/sec/credentials-prod.yml
+resource_types:
+- name: ya-git
+  type: docker-image
+  source:
+    repository: whitestar/git-resource
+    registry_mirror: https://((registry-mirror-domain))
+    ca_certs:
+    - domain: ((registry-mirror-domain))
+      cert: ((docker-reg-ca-cert))
+
+resources:
+- name: src-git
+  type: ya-git
+  #type: git
+  source:
+    uri: git://git.osdn.net/gitroot/metasearch/grid-chef-repo.git
+    branch: master
+    paths:
+    - cookbooks/((cookbook-name))
+    private_key: ((git-private-key))
+    git_user: ((git-user-osdn))
+  #check_every: 1h  # default: 1m
+- name: chefdk-cache
+  type: docker-image
+  source:
+    repository: chef/chefdk
+    tag: ((chefdk-version))
+    # ((param)) style: fly >= 3.2.0
+    registry_mirror: https://((registry-mirror-domain))  # e.g. https://registry.docker.example.com:5000
+    ca_certs:
+    - domain: ((registry-mirror-domain))  # e.g. registry.docker.example.com:5000
+      cert: ((docker-reg-ca-cert))
+  check_every: 12h  # default: 1m
+
+jobs:
+- name: test-cookbook
+  plan:
+  - aggregate:
+    - get: src-git
+      params:
+        depth: 5
+      trigger: true
+    - get: chefdk-cache
+  - task: ci-build
+    image: chefdk-cache
+    params:
+      http_proxy: ((http-proxy))  # e.g. http://proxy.example.com:3128
+      #HTTP_PROXY: ((http-proxy))
+    config:
+      platform: linux
+      #image_resource:
+      #  type: docker-image
+      #  source:
+      #    repository: chef/chefdk
+      #    tag: ((chefdk-version))
+          # NG, setting disable
+          #registry_mirror: https://((registry-mirror-domain))
+          #ca_certs:
+          #- domain: ((registry-mirror-domain))
+          #  cert: ((docker-reg-ca-cert))
+      inputs:
+      - name: src-git
+      run:
+        #dir: ./src-git/cookbooks/((cookbook-name))
+        #path: rake
+        path: /bin/bash
+        args:
+        - -c
+        - |
+          cd ./src-git/cookbooks/((cookbook-name))
+          bundle install
+          rake
+- name: publish-cookbook
+  plan:
+  - aggregate:
+    - get: src-git
+      params:
+        depth: 5
+      trigger: false
+    - get: chefdk-cache
+  - task: publish
+    image: chefdk-cache
+    params:
+      http_proxy: ((http-proxy))
+      chef_username: ((chef-username))
+      chef_client_key: ((chef-client-key))
+    config:
+      platform: linux
+      inputs:
+      - name: src-git
+      run:
+        path: /bin/bash
+        args:
+        - -c
+        - |
+          echo '{"username":"((chef-username))","key":"/root/chef-client-key.pem"}' > /root/.stove
+          echo "$chef_client_key"  > /root/chef-client-key.pem
+          cd ./src-git/cookbooks/((cookbook-name))
+          bundle install
+          rake publish
+  - put: src-git
+    params:
+      repository: src-git
+      tag_prefix: ((cookbook-name))-
+      tag: src-git/cookbooks/((cookbook-name))/version
+      only_tag: true
+      annotate: src-git/cookbooks/((cookbook-name))/version
+      #annotate:   # path to a file containing the annotation message.
diff --git a/cookbooks/apt_utils/fly-vars.yml b/cookbooks/apt_utils/fly-vars.yml
new file mode 100644 (file)
index 0000000..c050396
--- /dev/null
@@ -0,0 +1,3 @@
+---
+cookbook-name: apt_utils
+chefdk-version: 1.4.3
index c656e71..a1ac483 100644 (file)
@@ -5,10 +5,11 @@ maintainer_email ''
 license          'Apache 2.0'
 description      'Installs/Configures APT'
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version          '0.2.0'
+version          IO.read(File.join(File.dirname(__FILE__), 'version')).chomp
 source_url       'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
 issues_url       'https://osdn.jp/projects/metasearch/ticket'
 
+chef_version     '>= 12'
 %w( debian ubuntu ).each do |os|
   supports os
 end
diff --git a/cookbooks/apt_utils/recipes/aptly.rb b/cookbooks/apt_utils/recipes/aptly.rb
new file mode 100644 (file)
index 0000000..c90aaf0
--- /dev/null
@@ -0,0 +1,76 @@
+#
+# Cookbook Name:: apt_utils
+# Recipe:: aptly
+#
+# 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.
+#
+
+platform = node['platform']
+platform_version = node['platform_version']
+
+apt_get_update = 'apt-get_update'
+resources(execute: apt_get_update) rescue execute apt_get_update do
+  command 'apt-get update'
+  action :nothing
+end
+
+apt_repo_config = node['apt_utils']['aptly']['apt_repo']
+bash 'apt-key_adv_aptly_key' do
+  code <<-"EOH"
+    apt-key adv --keyserver #{apt_repo_config['keyserver']} --recv-keys #{apt_repo_config['recv-keys']}
+  EOH
+  action :nothing
+  notifies :run, "execute[#{apt_get_update}]", :immediately
+  not_if "apt-key list | grep 'Andrey Smirnov'"
+end
+
+if (platform == 'debian' && platform_version < '8.0') \
+  || (platform == 'ubuntu' && platform_version < '16.04')
+  template '/etc/apt/sources.list.d/aptly.list' do
+    source  'etc/apt/sources.list.d/aptly.list'
+    owner 'root'
+    group 'root'
+    mode '0644'
+    notifies :run, 'bash[apt-key_adv_aptly_key]', :before
+    notifies :run, "execute[#{apt_get_update}]", :immediately
+  end
+end
+
+pkg_name = 'aptly'
+resources(package: pkg_name) rescue package pkg_name do
+  action :install
+  notifies :run, 'bash[apt-key_adv_aptly_key]', :before
+end
+
+template '/etc/aptly.conf' do
+  source  'etc/aptly.conf'
+  owner 'root'
+  group 'root'
+  mode '0644'
+  action :create
+end
+
+aptly_user = node['apt_utils']['aptly']['user']
+user aptly_user do
+  action :create
+  not_if { aptly_user == 'root' }
+end
+
+directory node['apt_utils']['aptly']['conf']['rootDir'] do
+  owner aptly_user
+  group 'root'
+  mode '0755'
+  action :create
+end
diff --git a/cookbooks/apt_utils/templates/default/etc/apt/sources.list.d/aptly.list b/cookbooks/apt_utils/templates/default/etc/apt/sources.list.d/aptly.list
new file mode 100644 (file)
index 0000000..9834376
--- /dev/null
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+
+deb http://repo.aptly.info/ squeeze main
diff --git a/cookbooks/apt_utils/templates/default/etc/aptly.conf b/cookbooks/apt_utils/templates/default/etc/aptly.conf
new file mode 100644 (file)
index 0000000..54be79b
--- /dev/null
@@ -0,0 +1,5 @@
+<%
+require 'json'
+json_str = JSON.pretty_generate(node['apt_utils']['aptly']['conf'].to_hash)
+-%>
+<%= json_str %>
diff --git a/cookbooks/apt_utils/version b/cookbooks/apt_utils/version
new file mode 100644 (file)
index 0000000..0c62199
--- /dev/null
@@ -0,0 +1 @@
+0.2.1