Enabled: false
Metrics/AbcSize:
Enabled: false
+Metrics/BlockLength:
+ Max: 50
Style/BlockComments:
Enabled: false
Style/BlockDelimiters:
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:
# 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
apt_utils CHANGELOG
===================
+0.2.1
+-----
+- adds the `apt_utils::aptly` recipe.
+
0.2.0
-----
- adds the `apt_utils::apt` recipe.
--- /dev/null
+source 'https://rubygems.org'
+
+# with Chef DK
+gem 'stove'
## 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
|`['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'`|
- 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.
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|
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']
#'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'
--- /dev/null
+---
+# $ 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.
--- /dev/null
+---
+cookbook-name: apt_utils
+chefdk-version: 1.4.3
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
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
--- /dev/null
+<%
+require 'json'
+json_str = JSON.pretty_generate(node['apt_utils']['aptly']['conf'].to_hash)
+-%>
+<%= json_str %>