Update more cookbooks
This commit is contained in:
1
cookbooks/hostname/.gitignore
vendored
1
cookbooks/hostname/.gitignore
vendored
@@ -13,3 +13,4 @@ Gemfile.lock
|
||||
\#*#
|
||||
bin/*
|
||||
metadata.json
|
||||
Gemfile.lock
|
||||
|
||||
@@ -4,58 +4,31 @@ driver_config:
|
||||
require_chef_omnibus: true
|
||||
|
||||
platforms:
|
||||
- name: ubuntu-14.04
|
||||
driver_config:
|
||||
box: opscode_ubuntu-14.04_provisionerless
|
||||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box
|
||||
- name: ubuntu-12.04
|
||||
driver_config:
|
||||
box: opscode_ubuntu-12.04_provisionerless
|
||||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box
|
||||
- name: ubuntu-10.04
|
||||
driver_config:
|
||||
box: opscode_ubuntu-10.04_provisionerless
|
||||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-10.04_chef-provisionerless.box
|
||||
- name: debian-6
|
||||
driver_config:
|
||||
box: opscode_debian-6.0.8_provisionerless
|
||||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-6.0.8_chef-provisionerless.box
|
||||
- name: debian-7
|
||||
driver_config:
|
||||
box: opscode_debian-7.2.0_provisionerless
|
||||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.2.0_chef-provisionerless.box
|
||||
- name: centos-6.4
|
||||
driver_config:
|
||||
box: opscode_centos-6.4_provisionerless
|
||||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.4_chef-provisionerless.box
|
||||
#- name: freebsd-9.2
|
||||
# driver_config:
|
||||
# box: opscode_freebsd-9.2_provisionerless
|
||||
# box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_freebsd-9.2_chef-provisionerless.box
|
||||
- name: freebsd-10
|
||||
driver_config:
|
||||
box: opscode_freebsd-10.0_provisionerless
|
||||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_freebsd-10.0_chef-provisionerless.box
|
||||
- name: fedora-19
|
||||
driver_config:
|
||||
box: opscode_fedora-19_chef-provisionerless
|
||||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_fedora-19_chef-provisionerless.box
|
||||
- name: fedora-20
|
||||
driver_config:
|
||||
box: opscode_fedora-20_chef-provisionerless
|
||||
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_fedora-20_chef-provisionerless.box
|
||||
- name: ubuntu-12.04
|
||||
- name: ubuntu-14.04
|
||||
- name: ubuntu-16.04
|
||||
- name: debian-7.11
|
||||
- name: debian-8.5
|
||||
- name: centos-6.8
|
||||
- name: centos-7.2
|
||||
- name: freebsd-9.3
|
||||
- name: freebsd-10.3
|
||||
- name: fedora-21
|
||||
- name: fedora-22
|
||||
- name: fedora-23
|
||||
- name: fedora-24
|
||||
|
||||
suites:
|
||||
- name: default
|
||||
run_list:
|
||||
- recipe[hostname::default]
|
||||
attributes:
|
||||
set_fqdn: test.example.com
|
||||
- name: wildcard
|
||||
run_list:
|
||||
- recipe[hostname::default]
|
||||
provisioner:
|
||||
solo_rb:
|
||||
node_name: test
|
||||
attributes:
|
||||
set_fqdn: '*.example.com'
|
||||
- name: default
|
||||
run_list:
|
||||
- recipe[hostname::default]
|
||||
attributes:
|
||||
set_fqdn: test.example.com
|
||||
- name: wildcard
|
||||
run_list:
|
||||
- recipe[hostname::default]
|
||||
provisioner:
|
||||
solo_rb:
|
||||
node_name: test
|
||||
attributes:
|
||||
set_fqdn: '*.example.com'
|
||||
|
||||
1
cookbooks/hostname/.rspec
Normal file
1
cookbooks/hostname/.rspec
Normal file
@@ -0,0 +1 @@
|
||||
--color
|
||||
@@ -1,12 +1,23 @@
|
||||
AllCops:
|
||||
DisplayCopNames: true
|
||||
Exclude:
|
||||
- tmp/**
|
||||
|
||||
Documentation:
|
||||
Lint/AmbiguousBlockAssociation:
|
||||
Enabled: false
|
||||
|
||||
LineLength:
|
||||
Metrics/BlockLength:
|
||||
Enabled: false
|
||||
|
||||
SingleSpaceBeforeFirstArg:
|
||||
Metrics/LineLength:
|
||||
Enabled: false
|
||||
|
||||
Style/Documentation:
|
||||
Exclude:
|
||||
- Thorfile
|
||||
|
||||
Style/PercentLiteralDelimiters:
|
||||
Enabled: false
|
||||
|
||||
Style/SingleSpaceBeforeFirstArg:
|
||||
Enabled: false
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
bundler_args: --without integration
|
||||
before_script: bundle exec berks install
|
||||
script: bundle exec strainer test
|
||||
script: bundle exec rake
|
||||
language: ruby
|
||||
rvm:
|
||||
- 1.9.3
|
||||
- 2.3.1
|
||||
sudo: false
|
||||
notifications:
|
||||
hipchat:
|
||||
secure: ! 'mTePogP3SZVXbZ8l3o1yN+uszEEwQY3WgBXXXQc4hV1nLGhAXgjgj5ueCKAE
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*- ruby -*-
|
||||
source "https://supermarket.getchef.com"
|
||||
source 'https://supermarket.getchef.com'
|
||||
|
||||
metadata
|
||||
|
||||
group :integration do
|
||||
cookbook "minitest-handler"
|
||||
cookbook 'minitest-handler'
|
||||
end
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# Change History
|
||||
|
||||
0.4.2 (2017-05-04)
|
||||
==================
|
||||
- #51: Make host file idempotent on RHEL
|
||||
- #52: Add `append_hostsfile_ip` logic for improved idempotence
|
||||
- #55: Ensure sysctl `kernel.hostname` set correctly on RHEL
|
||||
|
||||
0.4.1 (2017-04-24)
|
||||
==================
|
||||
- #43: Set unique hosts file entry for hostname
|
||||
- #44: Make hostname mapping to `127.0.0.1` optional
|
||||
- #59: Updates to resolve deprecations warnings
|
||||
- #60, #61: various test fixes
|
||||
|
||||
0.4.0 (2015-03-16)
|
||||
==================
|
||||
- #40: Use file resources with lazy eval and notifies to prevent network restarts from occurring on every chef run (Matt Kasa)
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'berkshelf'
|
||||
gem 'chef', '~> 11.10'
|
||||
gem 'chef', '~> 12.13'
|
||||
gem 'chefspec'
|
||||
gem 'foodcritic', '~> 3.0'
|
||||
gem 'foodcritic'
|
||||
gem 'rake'
|
||||
gem 'strainer'
|
||||
gem 'rubocop'
|
||||
|
||||
group :integration do
|
||||
gem 'test-kitchen', '~> 1.0'
|
||||
gem 'kitchen-vagrant'
|
||||
gem 'test-kitchen'
|
||||
end
|
||||
|
||||
20
cookbooks/hostname/LICENSE
Normal file
20
cookbooks/hostname/LICENSE
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2011-2017 Maciej Pasternacki
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,5 +1,7 @@
|
||||
# hostname cookbook
|
||||
|
||||
[](https://travis-ci.org/3ofcoins/chef-cookbook-hostname)
|
||||
[](https://supermarket.chef.io/cookbooks/hostname)
|
||||
## Description
|
||||
|
||||
Sets hostname and FQDN of the node. The latest code is hosted at
|
||||
@@ -30,7 +32,13 @@ and have node set its FQDN and hostname based on its chef node name
|
||||
|
||||
- `node['hostname_cookbook']['hostsfile_ip']` -- IP used in
|
||||
`/etc/hosts` to correctly set FQDN (default: `127.0.1.1`)
|
||||
- `node['hostname_cookbook']['hostsfile_aliases']` -- list of aliases used in
|
||||
`/etc/hosts` for the ip set above (default: [`hostname`])
|
||||
- `node['hostname_cookbook']['hostsfile_include_hostname_in_aliases']` -- whether to include the hostname
|
||||
at the end of the aliases list above (default: true)
|
||||
|
||||
- `node['hostname_cookbook']['append_hostsfile_ip']` -- Set to `false` to
|
||||
prevent an entry for the node's hostname from being appended in `/etc/hosts` (default: `true`)
|
||||
|
||||
## Recipes
|
||||
|
||||
|
||||
15
cookbooks/hostname/Rakefile
Normal file
15
cookbooks/hostname/Rakefile
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'foodcritic'
|
||||
require 'rspec/core/rake_task'
|
||||
require 'rubocop/rake_task'
|
||||
|
||||
RuboCop::RakeTask.new(:rubocop)
|
||||
|
||||
FoodCritic::Rake::LintTask.new do |t|
|
||||
t.options = {
|
||||
fail_tags: ['any']
|
||||
}
|
||||
end
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
|
||||
task default: %w[foodcritic rubocop spec]
|
||||
@@ -1,4 +0,0 @@
|
||||
rubocop: rubocop $COOKBOOK
|
||||
knife test: knife cookbook test $COOKBOOK
|
||||
foodcritic: foodcritic -c 11.6.0 --tags ~FC015 --epic-fail any $SANDBOX/$COOKBOOK
|
||||
chefspec: rspec $SANDBOX/$COOKBOOK
|
||||
@@ -13,13 +13,12 @@ And then, to install all cookbooks:
|
||||
Local
|
||||
-----
|
||||
|
||||
$ bundle exec strainer test
|
||||
$ bundle exec rake
|
||||
|
||||
The above runs:
|
||||
|
||||
- rubocop
|
||||
- `knife cookbook test` tests
|
||||
- Food Critic lint
|
||||
- rubocop lint
|
||||
- Foodcritic lint
|
||||
- Chefspec tests
|
||||
|
||||
Chefspec tests (the interesting part) are in `spec/`.
|
||||
|
||||
@@ -6,12 +6,12 @@ require 'bundler/setup'
|
||||
require 'shellwords'
|
||||
|
||||
class Cookbook < Thor
|
||||
COOKBOOK_NAME = 'hostname'
|
||||
COOKBOOK_CATEGORY = 'utilities'
|
||||
COOKBOOK_NAME = 'hostname'.freeze
|
||||
COOKBOOK_CATEGORY = 'utilities'.freeze
|
||||
|
||||
include Thor::Actions
|
||||
|
||||
desc :edit, "Edit cookbook in browser"
|
||||
desc :edit, 'Edit cookbook in browser'
|
||||
def edit
|
||||
open "http://community.opscode.com/cookbooks/#{COOKBOOK_NAME}/edit"
|
||||
end
|
||||
@@ -35,7 +35,7 @@ class Cookbook < Thor
|
||||
def open_cmd
|
||||
@open_cmd ||= %w[open xdg-open].find do |command|
|
||||
system "which #{command} >/dev/null 2>&1"
|
||||
$?.success?
|
||||
$CHILD_STATUS.success?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
default['hostname_cookbook']['hostsfile_ip'] = '127.0.1.1'
|
||||
default['hostname_cookbook']['hostsfile_ip_interface'] = 'lo0' if platform == 'freebsd'
|
||||
default['hostname_cookbook']['hostsfile_ip_interface'] = 'lo0' if node['platform'] == 'freebsd'
|
||||
default['hostname_cookbook']['hostsfile_aliases'] = []
|
||||
default['hostname_cookbook']['hostsfile_include_hostname_in_aliases'] = true
|
||||
default['hostname_cookbook']['append_hostsfile_ip'] = true
|
||||
|
||||
@@ -6,10 +6,15 @@ maintainer_email 'maciej@3ofcoins.net'
|
||||
license 'MIT'
|
||||
description 'Configures hostname and FQDN'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.4.0'
|
||||
version '0.4.2'
|
||||
|
||||
supports 'debian'
|
||||
supports 'ubuntu'
|
||||
supports 'freebsd'
|
||||
|
||||
depends 'hostsfile'
|
||||
|
||||
source_url 'https://github.com/3ofcoins/chef-cookbook-hostname' if respond_to?(:source_url)
|
||||
issues_url 'https://github.com/3ofcoins/chef-cookbook-hostname/issues' if respond_to?(:issues_url)
|
||||
|
||||
chef_version '>= 12.1' if respond_to?(:chef_version)
|
||||
|
||||
@@ -31,7 +31,10 @@ if fqdn
|
||||
fqdn =~ /^([^.]+)/
|
||||
hostname = Regexp.last_match[1]
|
||||
|
||||
case node['platform']
|
||||
aliases = node['hostname_cookbook']['hostsfile_aliases']
|
||||
aliases += [hostname] if node['hostname_cookbook']['hostsfile_include_hostname_in_aliases']
|
||||
|
||||
case node['platform_family']
|
||||
when 'freebsd'
|
||||
directory '/etc/rc.conf.d' do
|
||||
mode '0755'
|
||||
@@ -56,7 +59,7 @@ if fqdn
|
||||
notifies :reload, 'ohai[reload_hostname]', :immediately
|
||||
end
|
||||
|
||||
when 'centos', 'redhat', 'amazon', 'scientific'
|
||||
when 'rhel'
|
||||
service 'network' do
|
||||
action :nothing
|
||||
end
|
||||
@@ -66,6 +69,7 @@ if fqdn
|
||||
content lazy {
|
||||
::IO.read(hostfile).gsub(/^HOSTNAME=.*$/, "HOSTNAME=#{fqdn}")
|
||||
}
|
||||
not_if { ::IO.read(hostfile) =~ /^HOSTNAME=#{fqdn}$/ }
|
||||
notifies :reload, 'ohai[reload_hostname]', :immediately
|
||||
notifies :restart, 'service[network]', :delayed
|
||||
end
|
||||
@@ -73,10 +77,13 @@ if fqdn
|
||||
sysctl = '/etc/sysctl.conf'
|
||||
file sysctl do
|
||||
action :create
|
||||
regex = /^kernel\.hostname=.*/
|
||||
newline = "kernel.hostname=#{hostname}"
|
||||
content lazy {
|
||||
::IO.read(sysctl) + "kernel.hostname=#{hostname}\n"
|
||||
original = ::IO.read(sysctl)
|
||||
original.match(regex) ? original.gsub(regex, newline) : original + newline
|
||||
}
|
||||
not_if { ::IO.read(sysctl) =~ /^kernel\.hostname=#{hostname}$/ }
|
||||
not_if { ::IO.read(sysctl).scan(regex).last == newline }
|
||||
notifies :reload, 'ohai[reload_hostname]', :immediately
|
||||
notifies :restart, 'service[network]', :delayed
|
||||
end
|
||||
@@ -84,6 +91,14 @@ if fqdn
|
||||
only_if { node['hostname'] != hostname }
|
||||
notifies :reload, 'ohai[reload_hostname]', :immediately
|
||||
end
|
||||
# update /etc/hostname in RHEL7+
|
||||
file '/etc/hostname' do
|
||||
content "#{hostname}\n"
|
||||
mode '0644'
|
||||
only_if { ::File.exist?('/etc/hostname') }
|
||||
notifies :reload, 'ohai[reload_hostname]', :immediately
|
||||
end
|
||||
|
||||
else
|
||||
file '/etc/hostname' do
|
||||
content "#{hostname}\n"
|
||||
@@ -106,9 +121,11 @@ if fqdn
|
||||
hostsfile_entry 'set hostname' do
|
||||
ip_address node['hostname_cookbook']['hostsfile_ip']
|
||||
hostname fqdn
|
||||
aliases [hostname]
|
||||
aliases aliases
|
||||
unique true
|
||||
action :create
|
||||
notifies :reload, 'ohai[reload_hostname]', :immediately
|
||||
only_if { node['hostname_cookbook']['append_hostsfile_ip'] }
|
||||
end
|
||||
|
||||
ohai 'reload_hostname' do
|
||||
|
||||
Reference in New Issue
Block a user