Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure smart_proxy_ansible plugin
Closes GH-285
- Loading branch information
Showing
4 changed files
with
101 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# = Ansible proxy plugin | ||
# | ||
# This class installs Ansible support for Foreman proxy | ||
# | ||
# === Advanced parameters: | ||
# | ||
# $ansible_dir:: Ansible directory to search for available roles | ||
# | ||
# $working_dir:: A directory where the playbooks will be generated. | ||
# A tmp directory will be created when left blank | ||
# | ||
# $enabled:: Enables/disables the plugin | ||
# type:boolean | ||
# | ||
# $listen_on:: Proxy feature listens on https, http, or both | ||
# | ||
class foreman_proxy::plugin::ansible ( | ||
$enabled = $::foreman_proxy::plugin::ansible::params::enabled, | ||
$listen_on = $::foreman_proxy::plugin::ansible::params::listen_on, | ||
$ansible_dir = $::foreman_proxy::plugin::ansible::params::ansible_dir, | ||
$working_dir = $::foreman_proxy::plugin::ansible::params::working_dir, | ||
) inherits foreman_proxy::plugin::ansible::params { | ||
|
||
validate_bool($enabled) | ||
validate_listen_on($listen_on) | ||
validate_absolute_path($ansible_dir) | ||
if $working_dir { | ||
validate_absolute_path($working_dir) | ||
} | ||
|
||
include ::foreman_proxy::plugin::dynflow | ||
|
||
foreman_proxy::plugin { 'ansible': | ||
} -> | ||
foreman_proxy::settings_file { 'ansible': | ||
enabled => $enabled, | ||
listen_on => $listen_on, | ||
template_path => 'foreman_proxy/plugin/ansible.yml.erb', | ||
} ~> | ||
Service['smart_proxy_dynflow_core'] | ||
} |
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,7 @@ | ||
# Ansible proxy default parameters | ||
class foreman_proxy::plugin::ansible::params { | ||
$enabled = true | ||
$listen_on = 'https' | ||
$ansible_dir = '/etc/ansible' | ||
$working_dir = undef | ||
} |
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,45 @@ | ||
require 'spec_helper' | ||
|
||
describe 'foreman_proxy::plugin::ansible' do | ||
|
||
let :facts do | ||
on_supported_os['redhat-7-x86_64'] | ||
end | ||
|
||
describe 'with default settings' do | ||
let :pre_condition do | ||
"include foreman_proxy" | ||
end | ||
|
||
it { should contain_foreman_proxy__plugin('dynflow') } | ||
|
||
it 'should configure ansible.yml' do | ||
should contain_file('/etc/foreman-proxy/settings.d/ansible.yml'). | ||
with_content(/:enabled: https/). | ||
with_content(%r{:ansible_dir: /etc/ansible}) | ||
end | ||
end | ||
|
||
describe 'with override parameters' do | ||
let :pre_condition do | ||
"include foreman_proxy" | ||
end | ||
|
||
let :params do | ||
{ | ||
:enabled => true, | ||
:ansible_dir => '/etc/ansible-test', | ||
:working_dir => '/tmp' | ||
} | ||
end | ||
|
||
it { should contain_foreman_proxy__plugin('dynflow') } | ||
|
||
it 'should configure ansible.yml' do | ||
should contain_file('/etc/foreman-proxy/settings.d/ansible.yml'). | ||
with_content(/:enabled: https/). | ||
with_content(%r{:ansible_dir: /etc/ansible-test}). | ||
with_content(%r{:working_dir: /tmp}) | ||
end | ||
end | ||
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 @@ | ||
--- | ||
:enabled: <%= @module_enabled %> | ||
:ansible_dir: <%= scope.lookupvar("foreman_proxy::plugin::ansible::ansible_dir") %> | ||
<% if [nil, :undefined, :undef].include?(scope.lookupvar("foreman_proxy::plugin::ansible::working_dir")) -%> | ||
#:working_dir: /var/tmp | ||
<% else -%> | ||
:working_dir: <%= scope.lookupvar("foreman_proxy::plugin::ansible::working_dir") %> | ||
<% end -%> |