Update cookbooks
* Replace old nginx cookbook with new chef_nginx cookbooks * Update application cookbook
This commit is contained in:
25
cookbooks/zypper/CHANGELOG.md
Normal file
25
cookbooks/zypper/CHANGELOG.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# zypper CHANGELOG
|
||||
|
||||
## 0.4.0
|
||||
|
||||
- [tas50] - Add Whyrun support
|
||||
- [bluca] - Add repository priority attribute
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- [tas50] - Add issues_url, source_url, and chef_version to the metadata
|
||||
- [tas50] - Add Chefspec matchers for the repo LWRP
|
||||
- [tas50] - Add testing and metadata supports attribute for opensuseleap
|
||||
|
||||
## 0.2.1
|
||||
|
||||
- [gimler] - Use --non-interactive mode when running zypper refresh
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- [jarosser06] - Added Key attribute to allow importing a gpg key for a new repo
|
||||
- [jarosser06] - Renamed alias attribute to repo_name
|
||||
|
||||
## 0.1.0
|
||||
|
||||
- [jarosser06] - Initial release of zypper
|
||||
126
cookbooks/zypper/README.md
Normal file
126
cookbooks/zypper/README.md
Normal file
@@ -0,0 +1,126 @@
|
||||
# zypper Cookbook
|
||||
|
||||
Cookbook that provides a lwrp for zypper repositories and also a recipe to install and configure the smt-client for SLES.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Platforms
|
||||
|
||||
- SLES 11+
|
||||
- openSUSE 13+
|
||||
- openSUSE Leap
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 11+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
- none
|
||||
|
||||
## Attributes
|
||||
|
||||
### zypper::smt_client
|
||||
|
||||
Key | Type | Description | Default
|
||||
------------------------------- | ------ | ------------------- | ------------
|
||||
<tt>['zypper']['smt_host']</tt> | String | uri of the SMT host | <tt>nil</tt>
|
||||
|
||||
## Resource/Provider
|
||||
|
||||
## zypper_repo
|
||||
|
||||
### Actions
|
||||
|
||||
- **add** - adds a repo
|
||||
- **delete** - removes a repo
|
||||
|
||||
### Attributes
|
||||
|
||||
- **repo_name** - repo alias (name attribute)
|
||||
- **uri** - uri of the repo
|
||||
- **autorefresh** - enable autorefresh
|
||||
- **key** - location of repo key to import
|
||||
- **priority** - priority of the repo
|
||||
|
||||
## Example Usage
|
||||
|
||||
```ruby
|
||||
zypper_repo 'remove_dvd_repo' do
|
||||
action :remove
|
||||
repo_name 'SLES11SP3-x64 DVD1 Online'
|
||||
end
|
||||
|
||||
zypper_repo 'add_dvd_repo' do
|
||||
repo_name 'SLES11SP3-x64 DVD1 Online'
|
||||
uri 'http://demeter.uni-regensburg.de/SLES11SP3-x64/DVD1/'
|
||||
end
|
||||
|
||||
zypper_repo 'jenkins' do
|
||||
key 'http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key'
|
||||
uri 'http://pkg.jenkins-ci.org/opensuse/'
|
||||
end
|
||||
```
|
||||
|
||||
### zypper::smt_client
|
||||
|
||||
Just include `zypper::smt_client` in your node's `run_list` and set the `smt_host` attribute to your smt server:
|
||||
|
||||
```json
|
||||
{
|
||||
"name":"my_node",
|
||||
"normal": {
|
||||
"zypper": {
|
||||
"smt_host": "smt.example.com"
|
||||
}
|
||||
},
|
||||
"run_list": [
|
||||
"recipe[zypper]"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
To test with test kitchen you need to have a SLES Vagrant box already on your system(checkout github.com/opscode/bento). In order to test the smt recipe with your smt server set the SMT_HOST env variable to your smt host:
|
||||
|
||||
```shell
|
||||
export SMT_HOST=smt.example.com
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Fork the repository on Github
|
||||
2. Create a named feature branch (like `add_component_x`)
|
||||
3. Write you change
|
||||
4. Write tests for your change (if applicable)
|
||||
5. Run the tests, ensuring they all pass
|
||||
6. Submit a Pull Request using Github
|
||||
|
||||
## License and Authors
|
||||
|
||||
- Author:: Jim Rosser(jarosser06@gmail.com)
|
||||
|
||||
```text
|
||||
copyright (C) 2014-2016 Jim Rosser
|
||||
|
||||
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
cookbooks/zypper/attributes/default.rb
Normal file
1
cookbooks/zypper/attributes/default.rb
Normal file
@@ -0,0 +1 @@
|
||||
default['zypper']['smt_host'] = nil
|
||||
12
cookbooks/zypper/libraries/matchers.rb
Normal file
12
cookbooks/zypper/libraries/matchers.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
if defined?(ChefSpec)
|
||||
ChefSpec.define_matcher :zypper_repo
|
||||
|
||||
def add_zypper_repo(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:zypper_repo, :add, resource_name)
|
||||
end
|
||||
|
||||
def remove_zypper_repo(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:zypper_repo, :remove, resource_name)
|
||||
end
|
||||
end
|
||||
1
cookbooks/zypper/metadata.json
Normal file
1
cookbooks/zypper/metadata.json
Normal file
@@ -0,0 +1 @@
|
||||
{"name":"zypper","version":"0.4.0","description":"Provides resources for managing zypper repositories","long_description":"# zypper Cookbook\n\nCookbook that provides a lwrp for zypper repositories and also a recipe to install and configure the smt-client for SLES.\n\n## Requirements\n\n### Platforms\n\n- SLES 11+\n- openSUSE 13+\n- openSUSE Leap\n\n### Chef\n\n- Chef 11+\n\n### Cookbooks\n\n- none\n\n## Attributes\n\n### zypper::smt_client\n\nKey | Type | Description | Default\n------------------------------- | ------ | ------------------- | ------------\n<tt>['zypper']['smt_host']</tt> | String | uri of the SMT host | <tt>nil</tt>\n\n## Resource/Provider\n\n## zypper_repo\n\n### Actions\n\n- **add** - adds a repo\n- **delete** - removes a repo\n\n### Attributes\n\n- **repo_name** - repo alias (name attribute)\n- **uri** - uri of the repo\n- **autorefresh** - enable autorefresh\n- **key** - location of repo key to import\n- **priority** - priority of the repo\n\n## Example Usage\n\n```ruby\nzypper_repo 'remove_dvd_repo' do\n action :remove\n repo_name 'SLES11SP3-x64 DVD1 Online'\nend\n\nzypper_repo 'add_dvd_repo' do\n repo_name 'SLES11SP3-x64 DVD1 Online'\n uri 'http://demeter.uni-regensburg.de/SLES11SP3-x64/DVD1/'\nend\n\nzypper_repo 'jenkins' do\n key 'http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key'\n uri 'http://pkg.jenkins-ci.org/opensuse/'\nend\n```\n\n### zypper::smt_client\n\nJust include `zypper::smt_client` in your node's `run_list` and set the `smt_host` attribute to your smt server:\n\n```json\n{\n \"name\":\"my_node\",\n \"normal\": {\n \"zypper\": {\n \"smt_host\": \"smt.example.com\"\n }\n },\n \"run_list\": [\n \"recipe[zypper]\"\n ]\n}\n```\n\n## Testing\n\nTo test with test kitchen you need to have a SLES Vagrant box already on your system(checkout github.com/opscode/bento). In order to test the smt recipe with your smt server set the SMT_HOST env variable to your smt host:\n\n```shell\nexport SMT_HOST=smt.example.com\n```\n\n## Contributing\n\n1. Fork the repository on Github\n2. Create a named feature branch (like `add_component_x`)\n3. Write you change\n4. Write tests for your change (if applicable)\n5. Run the tests, ensuring they all pass\n6. Submit a Pull Request using Github\n\n## License and Authors\n\n- Author:: Jim Rosser(jarosser06@gmail.com)\n\n```text\ncopyright (C) 2014-2016 Jim Rosser\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the “Software”), to deal in the Software without restriction,\nincluding without limitation the rights to use, copy, modify, merge,\npublish, distribute, sublicense, and/or sell copies of the Software,\nand to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n```\n","maintainer":"Jim Rosser","maintainer_email":"jarosser06@gmail.com","license":"MIT","platforms":{"suse":">= 0.0.0","opensuse":">= 0.0.0","opensuseleap":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/jarosser06/chef-zypper","issues_url":"https://github.com/jarosser06/chef-zypper/issues","chef_version":[[">= 11"]],"ohai_version":[]}
|
||||
68
cookbooks/zypper/providers/repo.rb
Normal file
68
cookbooks/zypper/providers/repo.rb
Normal file
@@ -0,0 +1,68 @@
|
||||
require 'mixlib/shellout'
|
||||
|
||||
use_inline_resources
|
||||
|
||||
def whyrun_supported?
|
||||
true
|
||||
end
|
||||
|
||||
action :add do
|
||||
unless repo_exist?
|
||||
converge_by("add zypper repository '#{new_resource.repo_name}'") do
|
||||
unless new_resource.key.nil?
|
||||
install_curl
|
||||
import_key
|
||||
end
|
||||
command = 'zypper ar'
|
||||
command << ' -f' if new_resource.autorefresh
|
||||
command << " #{new_resource.uri} \"#{new_resource.repo_name}\""
|
||||
shellout = Mixlib::ShellOut.new(command, user: 'root').run_command
|
||||
if shellout.stderr.empty?
|
||||
set_priority
|
||||
else
|
||||
Chef::Log.error("Error adding repo: #{shellout.stderr}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :remove do
|
||||
if repo_exist?
|
||||
converge_by("remove zypper repository '#{new_resource.repo_name}'") do
|
||||
command = "zypper rr \"#{new_resource.repo_name}\""
|
||||
shellout = Mixlib::ShellOut.new(command, user: 'root').run_command
|
||||
Chef::Log.error("Error removing repo: #{shellout.stderr}") unless shellout.stderr.empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def repo_exist?
|
||||
command = "zypper repos | grep \"#{new_resource.repo_name}\""
|
||||
shellout = Mixlib::ShellOut.new(command, user: 'root').run_command
|
||||
if shellout.stdout.empty?
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def install_curl
|
||||
# Make sure curl is installed
|
||||
pkg = Chef::Resource::Package.new('curl', run_context)
|
||||
pkg.run_action :install
|
||||
end
|
||||
|
||||
def import_key
|
||||
cmd = Chef::Resource::Execute.new("import key for #{new_resource.repo_name}",
|
||||
run_context)
|
||||
cmd.command "rpm --import #{new_resource.key}"
|
||||
cmd.run_action :run
|
||||
end
|
||||
|
||||
def set_priority
|
||||
return if new_resource.priority.nil? || new_resource.priority <= 0
|
||||
command = 'zypper mr'
|
||||
command << " -p #{new_resource.priority} \"#{new_resource.repo_name}\""
|
||||
shellout = Mixlib::ShellOut.new(command, user: 'root').run_command
|
||||
Chef::Log.error("Error setting repo priority: #{shellout.stderr}") unless shellout.stderr.empty?
|
||||
end
|
||||
30
cookbooks/zypper/recipes/default.rb
Normal file
30
cookbooks/zypper/recipes/default.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# Cookbook Name:: zypper
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2014 - 2016, Jim Rosser
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
execute 'zypper_refresh' do
|
||||
command 'zypper --non-interactive refresh'
|
||||
user 'root'
|
||||
end
|
||||
50
cookbooks/zypper/recipes/smt_client.rb
Normal file
50
cookbooks/zypper/recipes/smt_client.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# Cookbook Name:: zypper
|
||||
# Recipe:: smt_client
|
||||
#
|
||||
# Copyright 2014 - 2016, Jim Rosser
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
package 'smt-client'
|
||||
|
||||
client_setup = "#{Chef::Config[:file_cache_path]}/clientSetup4SMT.sh"
|
||||
register_log = '/root/.suse_register.log'
|
||||
|
||||
remote_file client_setup do
|
||||
action :create
|
||||
source "http://#{node['zypper']['smt_host']}/repo/tools/clientSetup4SMT.sh"
|
||||
mode 0544
|
||||
owner 'root'
|
||||
not_if { ::File.exist? register_log }
|
||||
end
|
||||
|
||||
execute 'register_smt' do
|
||||
command "yes | #{client_setup} --host #{node['zypper']['smt_host']}"
|
||||
user 'root'
|
||||
creates register_log
|
||||
notifies :run, 'execute[initial_smt_agent]', :immediately
|
||||
end
|
||||
|
||||
execute 'initial_smt_agent' do
|
||||
user 'root'
|
||||
command 'smt-agent'
|
||||
action :nothing
|
||||
end
|
||||
8
cookbooks/zypper/resources/repo.rb
Normal file
8
cookbooks/zypper/resources/repo.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
actions :add, :remove
|
||||
default_action :add
|
||||
|
||||
attribute :repo_name, kind_of: String, name_attribute: true
|
||||
attribute :autorefresh, kind_of: [TrueClass, FalseClass]
|
||||
attribute :uri, kind_of: String
|
||||
attribute :key, kind_of: String, default: nil
|
||||
attribute :priority, kind_of: Integer, default: nil
|
||||
Reference in New Issue
Block a user