-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add centos support #4
Open
jonathanmorley
wants to merge
6
commits into
Youscribe:master
Choose a base branch
from
cvent:centos-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
15f2193
Add centos support
jonathanmorley 09f348b
Support more centos versions
jonathanmorley 5a425cb
Use ohai init attribute
jonathanmorley 4ee07a5
Cleanup and move to custom resources
jonathanmorley 4dfaa3f
Remove debian-specific resource
jonathanmorley 62ab29a
Add new ubuntu to kitchen
jonathanmorley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
--- | ||
driver_plugin: vagrant | ||
driver_config: | ||
require_chef_omnibus: true | ||
driver: | ||
name: vagrant | ||
|
||
provisioner: | ||
name: chef_zero | ||
|
||
platforms: | ||
- name: ubuntu-12.04 | ||
driver_config: | ||
box: opscode-ubuntu-12.04 | ||
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box | ||
- name: ubuntu-10.04 | ||
driver_config: | ||
box: opscode-ubuntu-10.04 | ||
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box | ||
- name: centos-6.4 | ||
driver_config: | ||
box: opscode-centos-6.4 | ||
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box | ||
- name: centos-5.9 | ||
driver_config: | ||
box: opscode-centos-5.9 | ||
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box | ||
- name: debian-7.8 | ||
- name: ubuntu-10.04 | ||
- name: ubuntu-12.04 | ||
- name: ubuntu-14.10 | ||
- name: centos-6.6 | ||
- name: centos-7.0 | ||
|
||
suites: | ||
- name: default | ||
run_list: [] | ||
attributes: {} | ||
run_list: | ||
- recipe[sysfs::default] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
default['sysfs']['package'] = "sysfsutils" | ||
default['sysfs']['package'] = 'sysfsutils' | ||
default['sysfs']['service'] = 'sysfsutils' | ||
|
||
default['sysfs']['init_type'] = value_for_platform( | ||
%w(redhat centos) => { | ||
%w(6.0 6.1 6.2 6.3 6.4 6.5 6.6) => 'sysv', | ||
'default' => 'systemd' | ||
}, | ||
'default' => nil | ||
) | ||
|
||
default['sysfs']['disable_tuned'] = value_for_platform( | ||
%w(redhat centos) => { | ||
%w(6.0 6.1 6.2 6.3 6.4 6.5 6.6) => false, | ||
'default' => true | ||
}, | ||
'default' => false | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# /etc/sysfs.conf - Configuration file for setting sysfs attributes. | ||
# | ||
# The sysfs mount directory is automatically prepended to the attribute paths. | ||
# | ||
# Syntax: | ||
# attribute = value | ||
# mode attribute = 0600 # (any valid argument for chmod) | ||
# owner attribute = root:wheel # (any valid argument for chown) | ||
# | ||
# Examples: | ||
# | ||
# Always use the powersave CPU frequency governor | ||
# devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave | ||
# | ||
# Use userspace CPU frequency governor and set initial speed | ||
# devices/system/cpu/cpu0/cpufreq/scaling_governor = userspace | ||
# devices/system/cpu/cpu0/cpufreq/scaling_setspeed = 600000 | ||
# | ||
# Set permissions of suspend control file | ||
# mode power/state = 0660 | ||
# owner power/state = root:power |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#! /bin/sh -e | ||
|
||
### BEGIN INIT INFO | ||
# Provides: sysfsconf | ||
# Required-Start: mountkernfs | ||
# Should-Start: udev module-init-tools cpufrequtils | ||
# Required-Stop: | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: | ||
# Short-Description: Set sysfs variables from /etc/sysfs.conf | ||
# Description: Similarly to /etc/init.d/procps.sh, you can configure | ||
# values for sysfs variables (such as power management | ||
# defaults) and /sys file permissions in /etc/sysfs.conf. | ||
### END INIT INFO | ||
|
||
# /etc/init.d/sysfsutils: | ||
# | ||
# (c) 2005 Martin Pitt <[email protected]> | ||
|
||
CONFFILE=/etc/sysfs.conf | ||
CONFDIR=/etc/sysfs.d | ||
|
||
[ -r "$CONFFILE" -o -d "$CONFDIR" ] || exit 0 | ||
|
||
# RHEL does not have the init-functions file, so lets copy what we need | ||
#. /lib/lsb/init-functions | ||
log_begin_msg () { | ||
if [ -z "${1:-}" ]; then | ||
return 1 | ||
fi | ||
echo -n "$@" | ||
} | ||
|
||
log_failure_msg () { | ||
if [ -n "${1:-}" ]; then | ||
log_begin_msg $@ "..." | ||
fi | ||
log_end_msg 1 || true | ||
} | ||
|
||
log_end_msg_pre () { :; } | ||
log_end_msg_post () { :; } | ||
|
||
log_use_fancy_output () { | ||
TPUT=/usr/bin/tput | ||
EXPR=/usr/bin/expr | ||
if [ -t 1 ] && [ "x${TERM:-}" != "x" ] && [ "x${TERM:-}" != "xdumb" ] && [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1 && $TPUT setaf 1 >/dev/null 2>&1; then | ||
[ -z $FANCYTTY ] && FANCYTTY=1 || true | ||
else | ||
FANCYTTY=0 | ||
fi | ||
case "$FANCYTTY" in | ||
1|Y|yes|true) true;; | ||
*) false;; | ||
esac | ||
} | ||
|
||
# int log_end_message (int exitstatus) | ||
log_end_msg () { | ||
# If no arguments were passed, return | ||
if [ -z "${1:-}" ]; then | ||
return 1 | ||
fi | ||
|
||
retval=$1 | ||
|
||
log_end_msg_pre "$@" | ||
|
||
# Only do the fancy stuff if we have an appropriate terminal | ||
# and if /usr is already mounted | ||
if log_use_fancy_output; then | ||
RED=`$TPUT setaf 1` | ||
YELLOW=`$TPUT setaf 3` | ||
NORMAL=`$TPUT op` | ||
else | ||
RED='' | ||
YELLOW='' | ||
NORMAL='' | ||
fi | ||
|
||
if [ $1 -eq 0 ]; then | ||
echo "." | ||
elif [ $1 -eq 255 ]; then | ||
/bin/echo -e " ${YELLOW}(warning).${NORMAL}" | ||
else | ||
/bin/echo -e " ${RED}failed!${NORMAL}" | ||
fi | ||
log_end_msg_post "$@" | ||
return $retval | ||
} | ||
|
||
# End of copy | ||
|
||
load_conffile() { | ||
FILE="$1" | ||
sed 's/#.*$//; /^[[:space:]]*$/d; | ||
s/^[[:space:]]*\([^=[:space:]]*\)[[:space:]]*\([^=[:space:]]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1 \2 \3/' \ | ||
$FILE | { | ||
while read f1 f2 f3; do | ||
if [ "$f1" = "mode" -a -n "$f2" -a -n "$f3" ]; then | ||
if [ -f "/sys/$f2" ] || [ -d "/sys/$f2" ]; then | ||
chmod "$f3" "/sys/$f2" | ||
else | ||
log_failure_msg "unknown attribute $f2" | ||
fi | ||
elif [ "$f1" = "owner" -a -n "$f2" -a -n "$f3" ]; then | ||
if [ -f "/sys/$f2" ]; then | ||
chown "$f3" "/sys/$f2" | ||
else | ||
log_failure_msg "unknown attribute $f2" | ||
fi | ||
elif [ "$f1" -a -n "$f2" -a -z "$f3" ]; then | ||
if [ -f "/sys/$f1" ]; then | ||
# Some fields need a terminating newline, others | ||
# need the terminating newline to be absent :-( | ||
echo -n "$f2" > "/sys/$f1" 2>/dev/null || | ||
echo "$f2" > "/sys/$f1" | ||
else | ||
log_failure_msg "unknown attribute $f1" | ||
fi | ||
else | ||
log_failure_msg "syntax error in $CONFFILE: '$f1' '$f2' '$f3'" | ||
log_end_msg 1 | ||
exit 1 | ||
fi | ||
done | ||
} | ||
} | ||
|
||
case "$1" in | ||
start|restart|force-reload) | ||
log_begin_msg "Setting sysfs variables..." | ||
|
||
for file in $CONFFILE $CONFDIR/*.conf; do | ||
[ -r "$file" ] || continue | ||
load_conffile "$file" | ||
done | ||
|
||
log_end_msg 0 | ||
;; | ||
stop) | ||
;; | ||
*) | ||
echo "Usage: /etc/init.d/sysfsutils {start|stop|force-reload|restart}" | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Unit] | ||
Description=Sysfsutils Service | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/etc/init.d/sysfsutils start | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
name 'sysfs' | ||
name 'sysfs' | ||
maintainer "Guilhem Lettron" | ||
maintainer_email "[email protected]" | ||
license "Apache v2.0" | ||
description "Configures sysfs parameters" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version "0.0.2" | ||
version "0.1.0" | ||
supports "ubuntu" | ||
supports "debian" | ||
supports "centos" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# | ||
# Cookbook Name:: sysfs | ||
# Recipe:: systemd | ||
# Author:: Jonathan Morley <[email protected]> | ||
# | ||
# Copyright 2015, Cvent, Inc. | ||
# | ||
# 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. | ||
# | ||
|
||
include_recipe 'sysfs::sysv' | ||
|
||
cookbook_file '/etc/systemd/system/sysfsutils.service' do | ||
source 'sysfsutils.service' | ||
owner 'root' | ||
group 'root' | ||
mode '0644' | ||
action :create | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# | ||
# Cookbook Name:: sysfs | ||
# Recipe:: sysv | ||
# Author:: Jonathan Morley <[email protected]> | ||
# | ||
# Copyright 2015, Cvent, Inc. | ||
# | ||
# 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. | ||
# | ||
|
||
cookbook_file '/etc/sysfs.conf' do | ||
source 'sysfs.conf' | ||
owner 'root' | ||
group 'root' | ||
mode '0644' | ||
action :create | ||
end | ||
|
||
cookbook_file '/etc/init.d/sysfsutils' do | ||
source 'sysfsutils' | ||
owner 'root' | ||
group 'root' | ||
mode '0755' | ||
action :create | ||
end | ||
|
||
directory "/etc/sysfs.d" do | ||
owner 'root' | ||
group 'root' | ||
mode '0755' | ||
action :create | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'serverspec' | ||
|
||
# Required by serverspec | ||
set :backend, :exec | ||
|
||
describe service('sysfsutils') do | ||
it { should be_enabled } | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it not be better to do some detection rather than having to manage a list of versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, now detecting versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant something more along the lines of some helper functions detect the presence of systemd, upstart, and fall back to sysvinit:
We can still choose to overwrite it if we want (such as in a docker container where you would never run systemd) but we can try doing some sane default detection.