forked from redhat-openstack/astapor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jordan OMara
committed
May 29, 2013
1 parent
cbc4ba3
commit e25b815
Showing
113 changed files
with
5,848 additions
and
42 deletions.
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,42 +0,0 @@ | ||
[submodule "installer_puppet/tftp"] | ||
path = installer_puppet/tftp | ||
url = git://github.com/theforeman/puppet-tftp.git | ||
[submodule "installer_puppet/apache"] | ||
path = installer_puppet/apache | ||
url = git://github.com/theforeman/puppet-apache.git | ||
[submodule "installer_puppet/xinetd"] | ||
path = installer_puppet/xinetd | ||
url = git://github.com/puppetlabs/puppetlabs-xinetd.git | ||
[submodule "installer_puppet/git"] | ||
path = installer_puppet/git | ||
url = git://github.com/theforeman/puppet-git.git | ||
[submodule "installer_puppet/dhcp"] | ||
path = installer_puppet/dhcp | ||
url = git://github.com/theforeman/puppet-dhcp | ||
[submodule "installer_puppet/dns"] | ||
path = installer_puppet/dns | ||
url = git://github.com/theforeman/puppet-dns | ||
[submodule "installer_puppet/concat_native"] | ||
path = installer_puppet/concat_native | ||
url = git://github.com/theforeman/puppet-concat.git | ||
[submodule "installer_puppet/mysql"] | ||
path = installer_puppet/mysql | ||
url = git://github.com/puppetlabs/puppetlabs-mysql.git | ||
[submodule "installer_puppet/stdlib"] | ||
path = installer_puppet/stdlib | ||
url = git://github.com/puppetlabs/puppetlabs-stdlib.git | ||
[submodule "installer_puppet/concat"] | ||
path = installer_puppet/concat | ||
url = git://github.com/ripienaar/puppet-concat.git | ||
[submodule "installer_puppet/puppet"] | ||
path = installer_puppet/puppet | ||
url = git://github.com/cwolferh/puppet-puppet | ||
[submodule "installer_puppet/foreman"] | ||
path = installer_puppet/foreman | ||
url = git://github.com/cwolferh/puppet-foreman | ||
[submodule "installer_puppet/foreman_proxy"] | ||
path = installer_puppet/foreman_proxy | ||
url = git://github.com/cwolferh/puppet-foreman_proxy | ||
[submodule "installer_puppet/passenger"] | ||
path = installer_puppet/passenger | ||
url = git://github.com/cwolferh/puppet-passenger | ||
Empty file.
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 @@ | ||
source :rubygems | ||
|
||
gem 'rake' | ||
gem 'rspec', '>2' | ||
gem 'rspec-puppet', '>=0.1.3' | ||
gem 'puppet', '>=2.7.1' | ||
gem 'puppetlabs_spec_helper', '>=0.2.0' | ||
gem 'puppet-lint', '>=0.3.2' |
Large diffs are not rendered by default.
Oops, something went wrong.
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,15 @@ | ||
name 'theforeman-foreman' | ||
version '1.2.0-rc1' | ||
source 'git://github.com/theforeman/puppet-foreman' | ||
author 'theforeman' | ||
license 'GPLv3+' | ||
summary 'Foreman server configuration' | ||
description 'Module for configuring Foreman' | ||
project_page 'http://github.com/theforeman/foreman-installer' | ||
|
||
dependency 'theforeman/apache', '>= 1.2.0-rc1' | ||
dependency 'theforeman/concat_native', '>= 1.2.0-rc1' | ||
dependency 'theforeman/passenger', '>= 1.2.0-rc1' | ||
|
||
dependency 'puppetlabs/mysql', '>= 1.2.0-rc1' | ||
dependency 'puppetlabs/postgresql', '>= 2.2.0' |
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,30 @@ | ||
# Puppet module for managing Foreman | ||
|
||
Installs and configures Foreman. | ||
|
||
Part of the Foreman installer: http://github.com/theforeman/foreman-installer | ||
|
||
# Contributing | ||
|
||
* Fork the project | ||
* Commit and push until you are happy with your contribution | ||
* Send a pull request with a description of your changes | ||
|
||
# More info | ||
|
||
See http://theforeman.org or at #theforeman irc channel on freenode | ||
|
||
Copyright (c) 2010-2013 Ohad Levy and their respective owners | ||
|
||
Except where specified in provided modules, this program and entire | ||
repository is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
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,24 @@ | ||
require 'rake' | ||
require 'rspec/core/rake_task' | ||
require 'puppet-lint/tasks/puppet-lint' | ||
|
||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"] | ||
PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}' | ||
|
||
desc "Run all RSpec code examples" | ||
RSpec::Core::RakeTask.new(:rspec) do |t| | ||
t.rspec_opts = File.read("spec/spec.opts").chomp || "" | ||
end | ||
|
||
SPEC_SUITES = (Dir.entries('spec') - ['.', '..','fixtures']).select {|e| File.directory? "spec/#{e}" } | ||
namespace :rspec do | ||
SPEC_SUITES.each do |suite| | ||
desc "Run #{suite} RSpec code examples" | ||
RSpec::Core::RakeTask.new(suite) do |t| | ||
t.pattern = "spec/#{suite}/**/*_spec.rb" | ||
t.rspec_opts = File.read("spec/spec.opts").chomp || "" | ||
end | ||
end | ||
end | ||
|
||
task :default => [:rspec, :lint] |
3 changes: 3 additions & 0 deletions
3
installer_puppet/puppet-foreman/lib/puppet/feature/foreman_api.rb
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,3 @@ | ||
require 'puppet/util/feature' | ||
|
||
Puppet.features.add(:foreman_api, :libs => %{foreman_api}) |
31 changes: 31 additions & 0 deletions
31
installer_puppet/puppet-foreman/lib/puppet/parser/functions/cache_data.rb
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,31 @@ | ||
require 'fileutils' | ||
require 'yaml' | ||
|
||
# Retrieves data from a cache file, or creates it with supplied data if the file doesn't exist | ||
# | ||
# Useful for having data that's randomly generated once on the master side (e.g. a password), but | ||
# then stays the same on subsequent runs. | ||
# | ||
# Usage: cache_data(name, initial_data) | ||
# Example: $password = cache_data("mysql_password", random_password(32)) | ||
module Puppet::Parser::Functions | ||
newfunction(:cache_data, :type => :rvalue) do |args| | ||
raise Puppet::ParseError, 'Usage: cache_data(name, initial_data)' unless args.size == 2 | ||
|
||
name = args[0] | ||
raise Puppet::ParseError, 'Must provide data name' unless name | ||
initial_data = args[1] | ||
|
||
cache_dir = File.join(Puppet[:vardir], 'foreman_cache_data') | ||
cache = File.join(cache_dir, name) | ||
if File.exists? cache | ||
YAML.load(File.read(cache)) | ||
else | ||
FileUtils.mkdir_p cache_dir unless File.exists? cache_dir | ||
File.open(cache, 'w', 0600) do |c| | ||
c.write(YAML.dump(initial_data)) | ||
end | ||
initial_data | ||
end | ||
end | ||
end |
53 changes: 53 additions & 0 deletions
53
installer_puppet/puppet-foreman/lib/puppet/parser/functions/foreman.rb
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,53 @@ | ||
# Query Foreman | ||
# example usage: | ||
# | ||
# query for hosts | ||
# ~~~~~~~~~~~~~~~ | ||
# $myhosts = foreman("hosts","facts.domain ~ lab") | ||
# returns all hosts which have lab as part of their domain. | ||
# | ||
# or a more complex search term | ||
# $myhosts = foreman("hosts", "hostgroup ~ web and environment = production and status.failed = 0 and facts.timezone = EST and last_report < \"1 hour ago\"" | ||
# | ||
# query for facts | ||
# ~~~~~~~~~~~~~~~ | ||
# get manufactor value for host "xyz" | ||
# $manufactor = foreman("fact_values", "name = manufacturer and host = xyz" | ||
# which in this case will return a hash | ||
# {"xyz":{"manufacturer":"LENOVO"}} | ||
|
||
require "net/http" | ||
require "net/https" | ||
require "uri" | ||
require "timeout" | ||
|
||
module Puppet::Parser::Functions | ||
newfunction(:foreman, :type => :rvalue) do |args| | ||
# extend this as required | ||
searchable_items = %w{ hosts puppetclasses fact_values environments hostgroups } | ||
item, search = args | ||
raise Puppet::ParseError, "Foreman: Invalid item to search on: #{item}, must be one of #{searchable_items.join(", ")}." unless searchable_items.include?(item) | ||
|
||
# URL to query | ||
foreman_url = "https://foreman" | ||
foreman_user = "admin" | ||
foreman_pass = "changeme" | ||
|
||
uri = URI.parse(foreman_url) | ||
http = Net::HTTP.new(uri.host, uri.port) | ||
http.use_ssl = true if uri.scheme == 'https' | ||
|
||
path = URI.escape("/#{item}?search=#{search}") | ||
req = Net::HTTP::Get.new(path) | ||
req.basic_auth(foreman_user, foreman_pass) | ||
req['Content-Type'] = 'application/json' | ||
req['Accept'] = 'application/json' | ||
|
||
begin | ||
Timeout::timeout(5) { PSON.parse http.request(req).body } | ||
rescue Exception => e | ||
raise Puppet::ParseError, "Failed to contact Foreman #{e}" | ||
end | ||
|
||
end | ||
end |
87 changes: 87 additions & 0 deletions
87
installer_puppet/puppet-foreman/lib/puppet/parser/functions/random_password.rb
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,87 @@ | ||
# | ||
# random_password.rb | ||
# | ||
# Copyright 2012 Krzysztof Wilczynski | ||
# | ||
# 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. | ||
# | ||
|
||
module Puppet::Parser::Functions | ||
newfunction(:random_password, :type => :rvalue, :doc => <<-EOS | ||
Returns a string of arbitrary length that contains randomly selected characters. | ||
Prototype: | ||
random_password(n) | ||
Where n is a non-negative numeric value that denotes length of the desired password. | ||
For example: | ||
Given the following statements: | ||
$a = 4 | ||
$b = 8 | ||
$c = 16 | ||
notice random_password($a) | ||
notice random_password($b) | ||
notice random_password($c) | ||
The result will be as follows: | ||
notice: Scope(Class[main]): fNDC | ||
notice: Scope(Class[main]): KcKDLrjR | ||
notice: Scope(Class[main]): FtvfvkS9j9wXLsd6 | ||
EOS | ||
) do |*arguments| | ||
# | ||
# This is to ensure that whenever we call this function from within | ||
# the Puppet manifest or alternatively form a template it will always | ||
# do the right thing ... | ||
# | ||
arguments = arguments.shift if arguments.first.is_a?(Array) | ||
|
||
raise Puppet::ParseError, "random_password(): Wrong number of arguments " + | ||
"given (#{arguments.size} for 1)" if arguments.size < 1 | ||
|
||
size = arguments.shift | ||
|
||
# This should cover all the generic numeric types present in Puppet ... | ||
unless size.class.ancestors.include?(Numeric) or size.is_a?(String) | ||
raise Puppet::ParseError, 'random_password(): Requires a numeric ' + | ||
'type to work with' | ||
end | ||
|
||
# Numbers in Puppet are often string-encoded which is troublesome ... | ||
if size.is_a?(String) and size.match(/^\d+$/) | ||
size = size.to_i | ||
else | ||
raise Puppet::ParseError, 'random_password(): Requires a non-negative ' + | ||
'integer value to work with' | ||
end | ||
|
||
# These are quite often confusing ... | ||
ambiguous_characters = %w(0 1 O I l) | ||
|
||
# Get allowed characters set ... | ||
set = ('a' .. 'z').to_a + ('A' .. 'Z').to_a + ('0' .. '9').to_a | ||
set = set - ambiguous_characters | ||
|
||
# Shuffle characters in the set at random and return desired number of them ... | ||
size.times.collect {|i| set[rand(set.size)] }.join | ||
end | ||
end | ||
|
||
# vim: set ts=2 sw=2 et : | ||
# encoding: utf-8 |
40 changes: 40 additions & 0 deletions
40
installer_puppet/puppet-foreman/lib/puppet/parser/functions/smartvar.rb
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,40 @@ | ||
# Query Foreman in order to resolv a smart variable | ||
# Foreman holds all the value names and their possible values, | ||
# this function simply ask foreman for the right value for this host. | ||
|
||
|
||
require "net/http" | ||
require "net/https" | ||
require "uri" | ||
require "timeout" | ||
|
||
module Puppet::Parser::Functions | ||
newfunction(:smartvar, :type => :rvalue) do |args| | ||
#URL to query | ||
foreman_url = "http://foreman" | ||
foreman_user = "admin" | ||
foreman_pass = "changeme" | ||
|
||
var = args[0] | ||
raise Puppet::ParseError, "Must provide a variable name to search for" if var.nil? | ||
|
||
fqdn = lookupvar("fqdn") | ||
|
||
uri = URI.parse(foreman_url) | ||
http = Net::HTTP.new(uri.host, uri.port) | ||
http.use_ssl = true if uri.scheme == 'https' | ||
|
||
path = URI.escape("/hosts/#{fqdn}/lookup_keys/#{var}") | ||
req = Net::HTTP::Get.new(path) | ||
req.basic_auth(foreman_user, foreman_pass) | ||
req['Content-Type'] = 'application/json' | ||
req['Accept'] = 'application/json' | ||
|
||
begin | ||
Timeout::timeout(5) { PSON.parse(http.request(req).body)["value"] } | ||
rescue Exception => e | ||
raise Puppet::ParseError, "Failed to contact Foreman #{e}" | ||
end | ||
|
||
end | ||
end |
46 changes: 46 additions & 0 deletions
46
installer_puppet/puppet-foreman/lib/puppet/provider/foreman_smartproxy/rest.rb
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,46 @@ | ||
Puppet::Type.type(:foreman_smartproxy).provide(:rest) do | ||
|
||
confine :feature => :foreman_api | ||
|
||
def smartProxies | ||
ForemanApi::Resources::SmartProxy.new( | ||
:base_url => resource[:base_url], | ||
:oauth => { | ||
:consumer_key => resource[:consumer_key], | ||
:consumer_secret => resource[:consumer_secret] | ||
} | ||
) | ||
end | ||
|
||
def proxy | ||
@proxy ||= smartProxies.index[0].find { |s| s['smart_proxy']['name'] == resource[:name] } | ||
end | ||
|
||
def id | ||
proxy ? proxy['smart_proxy']['id'] : nil | ||
end | ||
|
||
def exists? | ||
id != nil | ||
end | ||
|
||
def create | ||
smartProxies.create({ | ||
'smart_proxy' => {'name' => resource[:name], 'url' => resource[:url]} | ||
}) | ||
end | ||
|
||
def destroy | ||
smartProxies.destroy({'id' => id}) | ||
@proxy = nil | ||
end | ||
|
||
def url | ||
proxy ? proxy['smart_proxy']['url'] : nil | ||
end | ||
|
||
def url=(value) | ||
smartProxies.update({'id' => id, 'smart_proxy' => {'url' => value}}) | ||
end | ||
|
||
end |
Oops, something went wrong.