Dev set up
This commit is contained in:
9
ops/cookbooks/vendor/packagecloud/Gemfile
vendored
Normal file
9
ops/cookbooks/vendor/packagecloud/Gemfile
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# This gemfile provides additional gems for testing and releasing this cookbook
|
||||
# It is meant to be installed on top of ChefDK which provides the majority
|
||||
# of the necessary gems for testing this cookbook
|
||||
#
|
||||
# Run 'chef exec bundle install' to install these dependencies
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'stove'
|
13
ops/cookbooks/vendor/packagecloud/LICENSE
vendored
Normal file
13
ops/cookbooks/vendor/packagecloud/LICENSE
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
Copyright (C) 2014 Computology, LLC.
|
||||
|
||||
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.
|
91
ops/cookbooks/vendor/packagecloud/README.md
vendored
Normal file
91
ops/cookbooks/vendor/packagecloud/README.md
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
# packagecloud cookbook
|
||||
|
||||
This cookbook provides a resource for installing <https://packagecloud.io> repositories.
|
||||
|
||||
NOTE: Please see the Changelog below for important changes if upgrading from 0.0.19 to 0.1.0.
|
||||
|
||||
## Usage
|
||||
|
||||
Be sure to depend on `packagecloud` in `metadata.rb` so that the packagecloud resource will be loaded.
|
||||
|
||||
For public repos:
|
||||
|
||||
```ruby
|
||||
packagecloud_repo "computology/packagecloud-cookbook-test-public" do
|
||||
type "deb"
|
||||
end
|
||||
```
|
||||
|
||||
For private repos, you need to supply a `master_token`:
|
||||
|
||||
```ruby
|
||||
packagecloud_repo "computology/packagecloud-cookbook-test-private" do
|
||||
type "deb"
|
||||
master_token "762748f7ae0bfdb086dd539575bdc8cffdca78c6a9af0db9"
|
||||
end
|
||||
```
|
||||
|
||||
For packagecloud:enterprise users, add `base_url` to your resource:
|
||||
|
||||
```
|
||||
packagecloud_repo "computology/packagecloud-cookbook-test-private" do
|
||||
base_url "https://packages.example.com"
|
||||
type "deb"
|
||||
master_token "762748f7ae0bfdb086dd539575bdc8cffdca78c6a9af0db9"
|
||||
end
|
||||
```
|
||||
|
||||
For forcing the os and dist for repository install:
|
||||
|
||||
```
|
||||
packagecloud_repo 'computology/packagecloud-cookbook-test-public' do
|
||||
type 'rpm'
|
||||
force_os 'rhel'
|
||||
force_dist '6.5'
|
||||
end
|
||||
```
|
||||
|
||||
Valid options for `type` include `deb`, `rpm`, and `gem`.
|
||||
|
||||
This cookbook performs checks to determine if a package exists before attempting to install it. To enable proxy support _for these checks_ (not to be confused with proxy support for your package manager of choice), add the following attributes to your cookbook:
|
||||
|
||||
```
|
||||
default['packagecloud']['proxy_host'] = 'myproxy.organization.com'
|
||||
default['packagecloud']['proxy_port'] = '80'
|
||||
```
|
||||
|
||||
## Interactions with other cookbooks
|
||||
|
||||
On CentOS 5, the official chef yum cookbook overwrites the file `/etc/yum.conf` setting some default values. When it does this, the `cachedir` value is changed from the CentOS5 default to the default value in the cookbook. The result of this change is that any packagecloud repository installed _before_ a repository installed with the yum cookbook will appear as though it's gpg keys were not imported.
|
||||
|
||||
There are a few potential workarounds for this:
|
||||
|
||||
- Pass the "-y" flag to package resource using the `options` attribute. This should cause yum to import the GPG key automatically if it was not imported already.
|
||||
- Move your packagecloud repos so that they are installed last, after any/all repos installed via the yum cookbook.
|
||||
- Set the cachedir option in the chef yum cookbook to the system default value of `/var/cache/yum` using the `yum_globalconfig` resource.
|
||||
|
||||
CentOS 6 and 7 are not affected as the default `cachedir` value provided by the yum chef cookbook is set to the system default, unless you use the `yum_globalconfig` resource to set a custom cachedir. If you do set a custom `cachedir`, you should make sure to setup packagecloud repos after that resource is set so that the GPG keys end up in the right place.
|
||||
|
||||
## Changelog
|
||||
|
||||
See CHANGELOG.md for more recent changes.
|
||||
|
||||
## Credits
|
||||
|
||||
Computology, LLC.
|
||||
|
||||
## License
|
||||
|
||||
```
|
||||
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.
|
||||
```
|
9
ops/cookbooks/vendor/packagecloud/THANKS
vendored
Normal file
9
ops/cookbooks/vendor/packagecloud/THANKS
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
The following people have contributed to packagecloud chef cookbook (If you're not listed here and you should be, please let us know!):
|
||||
|
||||
THANKS
|
||||
------
|
||||
Guilhem Lettron (@guilhem)
|
||||
Michael S. Fischer (@mfischer-zd)
|
||||
Jeremy Bingham (@ctdk)
|
||||
James Le Cuirot (@chewi)
|
||||
Tim Smith (@tas50)
|
5
ops/cookbooks/vendor/packagecloud/Thorfile
vendored
Normal file
5
ops/cookbooks/vendor/packagecloud/Thorfile
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# encoding: utf-8
|
||||
|
||||
require 'bundler'
|
||||
require 'bundler/setup'
|
||||
require 'berkshelf/thor'
|
10
ops/cookbooks/vendor/packagecloud/attributes/default.rb
vendored
Normal file
10
ops/cookbooks/vendor/packagecloud/attributes/default.rb
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
default['packagecloud']['base_repo_path'] = '/install/repositories/'
|
||||
default['packagecloud']['gpg_key_path'] = '/gpgkey'
|
||||
default['packagecloud']['hostname_override'] = nil
|
||||
default['packagecloud']['proxy_host'] = nil
|
||||
default['packagecloud']['proxy_port'] = nil
|
||||
|
||||
default['packagecloud']['default_type'] = value_for_platform_family(
|
||||
'debian' => 'deb',
|
||||
%w(rhel fedora amazon) => 'rpm'
|
||||
)
|
107
ops/cookbooks/vendor/packagecloud/chefignore
vendored
Normal file
107
ops/cookbooks/vendor/packagecloud/chefignore
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
# Put files/directories that should be ignored in this file when uploading
|
||||
# to a chef-server or supermarket.
|
||||
# Lines that start with '# ' are comments.
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store
|
||||
Icon?
|
||||
nohup.out
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# SASS #
|
||||
########
|
||||
.sass-cache
|
||||
|
||||
# EDITORS #
|
||||
###########
|
||||
\#*
|
||||
.#*
|
||||
*~
|
||||
*.sw[a-z]
|
||||
*.bak
|
||||
REVISION
|
||||
TAGS*
|
||||
tmtags
|
||||
*_flymake.*
|
||||
*_flymake
|
||||
*.tmproj
|
||||
.project
|
||||
.settings
|
||||
mkmf.log
|
||||
|
||||
## COMPILED ##
|
||||
##############
|
||||
a.out
|
||||
*.o
|
||||
*.pyc
|
||||
*.so
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*/rdoc/
|
||||
|
||||
# Testing #
|
||||
###########
|
||||
.watchr
|
||||
.rspec
|
||||
spec/*
|
||||
spec/fixtures/*
|
||||
test/*
|
||||
features/*
|
||||
examples/*
|
||||
Guardfile
|
||||
Procfile
|
||||
.kitchen*
|
||||
.rubocop.yml
|
||||
spec/*
|
||||
Rakefile
|
||||
.travis.yml
|
||||
.foodcritic
|
||||
.codeclimate.yml
|
||||
|
||||
# SCM #
|
||||
#######
|
||||
.git
|
||||
*/.git
|
||||
.gitignore
|
||||
.gitmodules
|
||||
.gitconfig
|
||||
.gitattributes
|
||||
.svn
|
||||
*/.bzr/*
|
||||
*/.hg/*
|
||||
*/.svn/*
|
||||
|
||||
# Berkshelf #
|
||||
#############
|
||||
Berksfile
|
||||
Berksfile.lock
|
||||
cookbooks/*
|
||||
tmp
|
||||
|
||||
# Policyfile #
|
||||
##############
|
||||
Policyfile.rb
|
||||
Policyfile.lock.json
|
||||
|
||||
# Cookbooks #
|
||||
#############
|
||||
CONTRIBUTING*
|
||||
CHANGELOG*
|
||||
TESTING*
|
||||
MAINTAINERS.toml
|
||||
|
||||
# Strainer #
|
||||
############
|
||||
Colanderfile
|
||||
Strainerfile
|
||||
.colander
|
||||
.strainer
|
||||
|
||||
# Vagrant #
|
||||
###########
|
||||
.vagrant
|
||||
Vagrantfile
|
45
ops/cookbooks/vendor/packagecloud/libraries/helper.rb
vendored
Normal file
45
ops/cookbooks/vendor/packagecloud/libraries/helper.rb
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
require 'net/https'
|
||||
|
||||
module PackageCloud
|
||||
module Helper
|
||||
def get(uri, params)
|
||||
uri.query = URI.encode_www_form(params)
|
||||
req = Net::HTTP::Get.new(uri.request_uri)
|
||||
|
||||
req.basic_auth uri.user, uri.password if uri.user
|
||||
|
||||
proxy = node['packagecloud'].values_at('proxy_host', 'proxy_port')
|
||||
http = Net::HTTP.new(uri.hostname, uri.port, *(proxy if proxy.first))
|
||||
http.use_ssl = true
|
||||
|
||||
resp = http.start { |h| h.request(req) }
|
||||
|
||||
case resp
|
||||
when Net::HTTPSuccess
|
||||
resp
|
||||
else
|
||||
raise resp.inspect
|
||||
end
|
||||
end
|
||||
|
||||
def post(uri, params)
|
||||
req = Net::HTTP::Post.new(uri.request_uri)
|
||||
req.form_data = params
|
||||
|
||||
req.basic_auth uri.user, uri.password if uri.user
|
||||
|
||||
proxy = node['packagecloud'].values_at('proxy_host', 'proxy_port')
|
||||
http = Net::HTTP.new(uri.hostname, uri.port, *(proxy if proxy.first))
|
||||
http.use_ssl = true
|
||||
|
||||
resp = http.start { |h| h.request(req) }
|
||||
|
||||
case resp
|
||||
when Net::HTTPSuccess
|
||||
resp
|
||||
else
|
||||
raise resp.inspect
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
11
ops/cookbooks/vendor/packagecloud/libraries/matchers.rb
vendored
Normal file
11
ops/cookbooks/vendor/packagecloud/libraries/matchers.rb
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
if defined?(ChefSpec)
|
||||
ChefSpec.define_matcher :packagecloud_repo
|
||||
|
||||
def create_packagecloud_repo(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:packagecloud_repo, :add, resource_name)
|
||||
end
|
||||
|
||||
def add_packagecloud_repo(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:packagecloud_repo, :add, resource_name)
|
||||
end
|
||||
end
|
45
ops/cookbooks/vendor/packagecloud/metadata.json
vendored
Normal file
45
ops/cookbooks/vendor/packagecloud/metadata.json
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "packagecloud",
|
||||
"description": "Installs/Configures packagecloud.io repositories.",
|
||||
"long_description": "Installs/Configures packagecloud.io repositories.",
|
||||
"maintainer": "Joe Damato",
|
||||
"maintainer_email": "joe@packagecloud.io",
|
||||
"license": "Apache-2.0",
|
||||
"platforms": {
|
||||
"ubuntu": ">= 0.0.0",
|
||||
"debian": ">= 0.0.0",
|
||||
"redhat": ">= 0.0.0",
|
||||
"centos": ">= 0.0.0",
|
||||
"amazon": ">= 0.0.0",
|
||||
"oracle": ">= 0.0.0",
|
||||
"fedora": ">= 0.0.0",
|
||||
"scientific": ">= 0.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
},
|
||||
"providing": {
|
||||
|
||||
},
|
||||
"attributes": {
|
||||
|
||||
},
|
||||
"recipes": {
|
||||
|
||||
},
|
||||
"version": "1.0.1",
|
||||
"source_url": "https://github.com/computology/packagecloud-cookbook",
|
||||
"issues_url": "https://github.com/computology/packagecloud-cookbook/issues",
|
||||
"privacy": false,
|
||||
"chef_versions": [
|
||||
[
|
||||
">= 12.5"
|
||||
]
|
||||
],
|
||||
"ohai_versions": [
|
||||
|
||||
],
|
||||
"gems": [
|
||||
|
||||
]
|
||||
}
|
13
ops/cookbooks/vendor/packagecloud/metadata.rb
vendored
Normal file
13
ops/cookbooks/vendor/packagecloud/metadata.rb
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
name 'packagecloud'
|
||||
maintainer 'Joe Damato'
|
||||
maintainer_email 'joe@packagecloud.io'
|
||||
license 'Apache-2.0'
|
||||
description 'Installs/Configures packagecloud.io repositories.'
|
||||
long_description 'Installs/Configures packagecloud.io repositories.'
|
||||
version '1.0.1'
|
||||
source_url 'https://github.com/computology/packagecloud-cookbook' if respond_to?(:source_url)
|
||||
issues_url 'https://github.com/computology/packagecloud-cookbook/issues' if respond_to?(:issues_url)
|
||||
chef_version '>= 12.5' if respond_to?(:chef_version)
|
||||
%w(ubuntu debian redhat centos amazon oracle fedora scientific).each do |p|
|
||||
supports p
|
||||
end
|
246
ops/cookbooks/vendor/packagecloud/resources/repo.rb
vendored
Normal file
246
ops/cookbooks/vendor/packagecloud/resources/repo.rb
vendored
Normal file
@ -0,0 +1,246 @@
|
||||
property :repository, String, name_property: true
|
||||
property :master_token, String
|
||||
property :force_os, String
|
||||
property :force_dist, String
|
||||
property :type, String, equal_to: %w(deb rpm gem), default: lazy { node['packagecloud']['default_type'] }
|
||||
property :base_url, String, default: 'https://packagecloud.io'
|
||||
property :priority, [Integer, TrueClass, FalseClass], default: false
|
||||
property :metadata_expire, String, regex: [/^\d+[d|h|m]?$/], default: '300'
|
||||
|
||||
action :add do
|
||||
case new_resource.type
|
||||
when 'deb'
|
||||
install_deb
|
||||
when 'rpm'
|
||||
install_rpm
|
||||
when 'gem'
|
||||
install_gem
|
||||
else
|
||||
raise "#{new_resource.type} is an unknown package type."
|
||||
end
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
include ::PackageCloud::Helper
|
||||
|
||||
require 'uri'
|
||||
|
||||
def gpg_url(base_url, repo, format, master_token)
|
||||
base_install_url = ::File.join(base_url, node['packagecloud']['base_repo_path'])
|
||||
ext = (format == :deb) ? 'list' : 'repo'
|
||||
gpg_key_url_endpoint = construct_uri_with_options(base_url: base_install_url, repo: repo, endpoint: "gpg_key_url.#{ext}")
|
||||
unless master_token.nil?
|
||||
gpg_key_url_endpoint.user = master_token
|
||||
gpg_key_url_endpoint.password = ''
|
||||
end
|
||||
|
||||
URI(get(gpg_key_url_endpoint, install_endpoint_params).body.chomp)
|
||||
end
|
||||
|
||||
def install_deb
|
||||
base_url = new_resource.base_url
|
||||
repo_url = construct_uri_with_options(base_url: base_url, repo: new_resource.repository, endpoint: os_platform)
|
||||
|
||||
Chef::Log.debug("#{new_resource.name} deb repo url = #{repo_url}")
|
||||
|
||||
package 'wget'
|
||||
package 'apt-transport-https'
|
||||
package 'lsb-release'
|
||||
|
||||
ohai "reload-lsb-#{filename}" do
|
||||
plugin 'lsb'
|
||||
action :nothing
|
||||
subscribes :reload, 'package[lsb-release]', :immediately
|
||||
end
|
||||
|
||||
repo_url = read_token(repo_url)
|
||||
|
||||
template "/etc/apt/sources.list.d/#{filename}.list" do
|
||||
source 'apt.erb'
|
||||
cookbook 'packagecloud'
|
||||
mode '0644'
|
||||
variables lazy {
|
||||
{ base_url: repo_url.to_s,
|
||||
distribution: dist_name,
|
||||
component: 'main' }
|
||||
}
|
||||
|
||||
notifies :run, "execute[apt-key-add-#{filename}]", :immediately
|
||||
notifies :run, "execute[apt-get-update-#{filename}]", :immediately
|
||||
end
|
||||
|
||||
execute "apt-key-add-#{filename}" do # ~FC041
|
||||
command lazy {
|
||||
gpg_url = gpg_url(new_resource.base_url, new_resource.repository, :deb, new_resource.master_token)
|
||||
"wget --auth-no-challenge -qO - #{gpg_url} | apt-key add -"
|
||||
}
|
||||
action :nothing
|
||||
end
|
||||
|
||||
execute "apt-get-update-#{filename}" do
|
||||
command "apt-get update -o Dir::Etc::sourcelist=\"sources.list.d/#{filename}.list\"" \
|
||||
' -o Dir::Etc::sourceparts="-"' \
|
||||
' -o APT::Get::List-Cleanup="0"'
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
def install_rpm
|
||||
given_base_url = new_resource.base_url
|
||||
base_repo_url = ::File.join(given_base_url, node['packagecloud']['base_repo_path'])
|
||||
base_url_endpoint = construct_uri_with_options(base_url: base_repo_url, repo: new_resource.repository, endpoint: 'rpm_base_url')
|
||||
|
||||
if new_resource.master_token
|
||||
base_url_endpoint.user = new_resource.master_token
|
||||
base_url_endpoint.password = ''
|
||||
end
|
||||
|
||||
base_url = URI(get(base_url_endpoint, install_endpoint_params).body.chomp)
|
||||
|
||||
Chef::Log.debug("#{new_resource.name} rpm base url = #{base_url}")
|
||||
|
||||
package 'pygpgme' do
|
||||
ignore_failure true
|
||||
end
|
||||
|
||||
log 'pygpgme_warning' do
|
||||
message 'The pygpgme package could not be installed. This means GPG verification is not possible for any RPM installed on your system. ' \
|
||||
'To fix this, add a repository with pygpgme. Usualy, the EPEL repository for your system will have this. ' \
|
||||
'More information: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F and https://github.com/opscode-cookbooks/yum-epel'
|
||||
|
||||
level :warn
|
||||
not_if 'rpm -qa | grep -qw pygpgme'
|
||||
end
|
||||
|
||||
ruby_block 'disable repo_gpgcheck if no pygpgme' do
|
||||
block do
|
||||
template = run_context.resource_collection.find(template: "/etc/yum.repos.d/#{filename}.repo")
|
||||
template.variables[:repo_gpgcheck] = 0
|
||||
end
|
||||
not_if 'rpm -qa | grep -qw pygpgme'
|
||||
end
|
||||
|
||||
gpg_url = gpg_url(new_resource.base_url, new_resource.repository, :rpm, new_resource.master_token)
|
||||
|
||||
template "/etc/yum.repos.d/#{filename}.repo" do
|
||||
source 'yum.erb'
|
||||
cookbook 'packagecloud'
|
||||
mode '0644'
|
||||
variables base_url: base_url.to_s,
|
||||
name: filename,
|
||||
gpg_url: gpg_url.to_s,
|
||||
repo_gpgcheck: 1,
|
||||
description: filename,
|
||||
priority: new_resource.priority,
|
||||
metadata_expire: new_resource.metadata_expire
|
||||
|
||||
notifies :run, "execute[yum-makecache-#{filename}]", :immediately
|
||||
notifies :run, "ruby_block[yum-cache-reload-#{filename}]", :immediately
|
||||
end
|
||||
|
||||
# get the metadata for this repo only
|
||||
execute "yum-makecache-#{filename}" do
|
||||
command "yum -q makecache -y --disablerepo=* --enablerepo=#{filename}"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# reload internal Chef yum cache
|
||||
ruby_block "yum-cache-reload-#{filename}" do
|
||||
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
def install_gem
|
||||
base_url = new_resource.base_url
|
||||
|
||||
repo_url = construct_uri_with_options(base_url: base_url, repo: new_resource.repository)
|
||||
repo_url = read_token(repo_url, true).to_s
|
||||
|
||||
execute "install packagecloud #{new_resource.name} repo as gem source" do
|
||||
command "gem source --add #{repo_url}"
|
||||
not_if "gem source --list | grep #{repo_url}"
|
||||
end
|
||||
end
|
||||
|
||||
def read_token(repo_url, gems = false)
|
||||
return repo_url unless new_resource.master_token
|
||||
|
||||
base_url = new_resource.base_url
|
||||
|
||||
base_repo_url = ::File.join(base_url, node['packagecloud']['base_repo_path'])
|
||||
|
||||
uri = construct_uri_with_options(base_url: base_repo_url, repo: new_resource.repository, endpoint: 'tokens.text')
|
||||
uri.user = new_resource.master_token
|
||||
uri.password = ''
|
||||
|
||||
resp = post(uri, install_endpoint_params)
|
||||
|
||||
Chef::Log.debug("#{new_resource.name} TOKEN = #{resp.body.chomp}")
|
||||
|
||||
if rhel5? && !gems
|
||||
repo_url
|
||||
else
|
||||
repo_url.user = resp.body.chomp
|
||||
repo_url.password = ''
|
||||
repo_url
|
||||
end
|
||||
end
|
||||
|
||||
def install_endpoint_params
|
||||
dist = dist_name
|
||||
|
||||
hostname = node['packagecloud']['hostname_override'] ||
|
||||
node['fqdn'] ||
|
||||
node['hostname']
|
||||
|
||||
if !hostname || hostname.empty?
|
||||
raise("Can't determine hostname! Set node['packagecloud']['hostname_override'] " \
|
||||
'if it cannot be automatically determined by Ohai.')
|
||||
end
|
||||
|
||||
{ os: os_platform,
|
||||
dist: dist,
|
||||
name: hostname }
|
||||
end
|
||||
|
||||
def os_platform
|
||||
new_resource.force_os || node['platform']
|
||||
end
|
||||
|
||||
def dist_name
|
||||
new_resource.force_dist || value_for_platform_family(
|
||||
'debian' => node['lsb']['codename'],
|
||||
'amazon' => '6',
|
||||
%w(rhel fedora) => node['platform_version']
|
||||
)
|
||||
end
|
||||
|
||||
def filename
|
||||
new_resource.name.gsub(/[^0-9A-z.\-]/, '_')
|
||||
end
|
||||
|
||||
def rhel5?
|
||||
platform_family?('rhel') && node['platform_version'].to_i == 5
|
||||
end
|
||||
|
||||
def construct_uri_with_options(options)
|
||||
required_options = [:base_url, :repo]
|
||||
|
||||
required_options.each do |opt|
|
||||
unless options[opt]
|
||||
raise ArgumentError,
|
||||
"A required option :#{opt} was not specified"
|
||||
end
|
||||
end
|
||||
|
||||
options[:base_url] = append_trailing_slash(options[:base_url])
|
||||
options[:repo] = append_trailing_slash(options[:repo])
|
||||
|
||||
URI.join(options.delete(:base_url), options.inject([]) { |mem, opt| mem << opt[1] }.join)
|
||||
end
|
||||
|
||||
def append_trailing_slash(str)
|
||||
str.end_with?('/') ? str : str + '/'
|
||||
end
|
||||
end
|
2
ops/cookbooks/vendor/packagecloud/templates/default/apt.erb
vendored
Normal file
2
ops/cookbooks/vendor/packagecloud/templates/default/apt.erb
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
deb <%= @base_url %> <%= @distribution %> <%= @component %>
|
||||
deb-src <%= @base_url %> <%= @distribution %> <%= @component %>
|
15
ops/cookbooks/vendor/packagecloud/templates/default/yum.erb
vendored
Normal file
15
ops/cookbooks/vendor/packagecloud/templates/default/yum.erb
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
[<%= @name %>]
|
||||
name=<%= @description %>
|
||||
baseurl=<%= @base_url %>
|
||||
repo_gpgcheck=<%= @repo_gpgcheck %>
|
||||
<% if @priority -%>
|
||||
priority=<%=@priority %>
|
||||
<% end -%>
|
||||
gpgcheck=0
|
||||
enabled=1
|
||||
gpgkey=<%= @gpg_url %>
|
||||
sslverify=1
|
||||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
|
||||
<% if @metadata_expire %>
|
||||
metadata_expire=<%= @metadata_expire %>
|
||||
<% end %>
|
Reference in New Issue
Block a user