Skip to content

Commit

Permalink
Removing submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan OMara committed May 29, 2013
1 parent cbc4ba3 commit e25b815
Show file tree
Hide file tree
Showing 113 changed files with 5,848 additions and 42 deletions.
42 changes: 0 additions & 42 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,42 +0,0 @@
[submodule "installer_puppet/tftp"]
path = installer_puppet/tftp
url = git:https://github.com/theforeman/puppet-tftp.git
[submodule "installer_puppet/apache"]
path = installer_puppet/apache
url = git:https://github.com/theforeman/puppet-apache.git
[submodule "installer_puppet/xinetd"]
path = installer_puppet/xinetd
url = git:https://github.com/puppetlabs/puppetlabs-xinetd.git
[submodule "installer_puppet/git"]
path = installer_puppet/git
url = git:https://github.com/theforeman/puppet-git.git
[submodule "installer_puppet/dhcp"]
path = installer_puppet/dhcp
url = git:https://github.com/theforeman/puppet-dhcp
[submodule "installer_puppet/dns"]
path = installer_puppet/dns
url = git:https://github.com/theforeman/puppet-dns
[submodule "installer_puppet/concat_native"]
path = installer_puppet/concat_native
url = git:https://github.com/theforeman/puppet-concat.git
[submodule "installer_puppet/mysql"]
path = installer_puppet/mysql
url = git:https://github.com/puppetlabs/puppetlabs-mysql.git
[submodule "installer_puppet/stdlib"]
path = installer_puppet/stdlib
url = git:https://github.com/puppetlabs/puppetlabs-stdlib.git
[submodule "installer_puppet/concat"]
path = installer_puppet/concat
url = git:https://github.com/ripienaar/puppet-concat.git
[submodule "installer_puppet/puppet"]
path = installer_puppet/puppet
url = git:https://github.com/cwolferh/puppet-puppet
[submodule "installer_puppet/foreman"]
path = installer_puppet/foreman
url = git:https://github.com/cwolferh/puppet-foreman
[submodule "installer_puppet/foreman_proxy"]
path = installer_puppet/foreman_proxy
url = git:https://github.com/cwolferh/puppet-foreman_proxy
[submodule "installer_puppet/passenger"]
path = installer_puppet/passenger
url = git:https://github.com/cwolferh/puppet-passenger
Empty file.
8 changes: 8 additions & 0 deletions installer_puppet/puppet-foreman/Gemfile
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'
621 changes: 621 additions & 0 deletions installer_puppet/puppet-foreman/LICENSE

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions installer_puppet/puppet-foreman/Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name 'theforeman-foreman'
version '1.2.0-rc1'
source 'git:https://github.com/theforeman/puppet-foreman'
author 'theforeman'
license 'GPLv3+'
summary 'Foreman server configuration'
description 'Module for configuring Foreman'
project_page 'https://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'
30 changes: 30 additions & 0 deletions installer_puppet/puppet-foreman/README.md
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: https://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 https://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 <https://www.gnu.org/licenses/>.
24 changes: 24 additions & 0 deletions installer_puppet/puppet-foreman/Rakefile
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]
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})
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
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
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
#
# https://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
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 = "https://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
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
Loading

0 comments on commit e25b815

Please sign in to comment.