dopi 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +322 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +102 -0
- data/LICENSE.txt +177 -0
- data/README.md +309 -0
- data/Rakefile +44 -0
- data/Vagrantfile +64 -0
- data/bin/dopi +4 -0
- data/doc/getting_started.md +247 -0
- data/doc/getting_started_examples/001_hello_world.yaml +17 -0
- data/doc/getting_started_examples/002_connecting_over_ssh.yaml +35 -0
- data/doc/plugins/custom.md +88 -0
- data/doc/plugins/mco/rpc.md +82 -0
- data/doc/plugins/ssh/custom.md +141 -0
- data/doc/plugins/ssh/file_contains.md +37 -0
- data/doc/plugins/ssh/file_deploy.md +52 -0
- data/doc/plugins/ssh/file_exists.md +31 -0
- data/doc/plugins/ssh/file_replace.md +37 -0
- data/doc/plugins/ssh/puppet_agent_run.md +50 -0
- data/doc/plugins/ssh/reboot.md +22 -0
- data/doc/plugins/ssh/wait_for_login.md +53 -0
- data/doc/plugins/winrm/cmd.md +161 -0
- data/doc/plugins/winrm/file_contains.md +39 -0
- data/doc/plugins/winrm/file_exists.md +31 -0
- data/doc/plugins/winrm/powershell.md +27 -0
- data/doc/plugins/winrm/puppet_agent_run.md +49 -0
- data/doc/plugins/winrm/reboot.md +17 -0
- data/doc/plugins/winrm/wait_for_login.md +55 -0
- data/dopi.gemspec +42 -0
- data/lib/dopi/cli/command_add.rb +35 -0
- data/lib/dopi/cli/command_list.rb +19 -0
- data/lib/dopi/cli/command_remove.rb +31 -0
- data/lib/dopi/cli/command_reset.rb +27 -0
- data/lib/dopi/cli/command_run.rb +68 -0
- data/lib/dopi/cli/command_show.rb +109 -0
- data/lib/dopi/cli/command_update.rb +37 -0
- data/lib/dopi/cli/command_validate.rb +27 -0
- data/lib/dopi/cli/global_options.rb +55 -0
- data/lib/dopi/cli/log.rb +33 -0
- data/lib/dopi/cli.rb +57 -0
- data/lib/dopi/command/custom.rb +52 -0
- data/lib/dopi/command/dummy.rb +27 -0
- data/lib/dopi/command/mco/rpc.rb +158 -0
- data/lib/dopi/command/ssh/custom.rb +48 -0
- data/lib/dopi/command/ssh/file_contains.rb +70 -0
- data/lib/dopi/command/ssh/file_deploy.rb +71 -0
- data/lib/dopi/command/ssh/file_exists.rb +54 -0
- data/lib/dopi/command/ssh/file_replace.rb +96 -0
- data/lib/dopi/command/ssh/puppet_agent_run.rb +63 -0
- data/lib/dopi/command/ssh/reboot.rb +50 -0
- data/lib/dopi/command/ssh/wait_for_login.rb +68 -0
- data/lib/dopi/command/winrm/cmd.rb +44 -0
- data/lib/dopi/command/winrm/file_contains.rb +66 -0
- data/lib/dopi/command/winrm/file_exists.rb +51 -0
- data/lib/dopi/command/winrm/powershell.rb +16 -0
- data/lib/dopi/command/winrm/puppet_agent_run.rb +61 -0
- data/lib/dopi/command/winrm/reboot.rb +33 -0
- data/lib/dopi/command/winrm/wait_for_login.rb +49 -0
- data/lib/dopi/command.rb +239 -0
- data/lib/dopi/command_parser/arguments.rb +38 -0
- data/lib/dopi/command_parser/credentials.rb +59 -0
- data/lib/dopi/command_parser/env.rb +37 -0
- data/lib/dopi/command_parser/exec.rb +27 -0
- data/lib/dopi/command_parser/exit_code.rb +73 -0
- data/lib/dopi/command_parser/output.rb +126 -0
- data/lib/dopi/command_set.rb +66 -0
- data/lib/dopi/connector/local.rb +77 -0
- data/lib/dopi/connector/ssh.rb +170 -0
- data/lib/dopi/connector/winrm.rb +167 -0
- data/lib/dopi/error.rb +43 -0
- data/lib/dopi/log.rb +18 -0
- data/lib/dopi/node.rb +70 -0
- data/lib/dopi/plan.rb +99 -0
- data/lib/dopi/pluginmanager.rb +62 -0
- data/lib/dopi/state.rb +226 -0
- data/lib/dopi/state_store.rb +155 -0
- data/lib/dopi/step.rb +227 -0
- data/lib/dopi/step_set.rb +70 -0
- data/lib/dopi/version.rb +3 -0
- data/lib/dopi.rb +165 -0
- data/spec/command_helper.rb +11 -0
- data/spec/fixtures/mco_client.cfg +26 -0
- data/spec/fixtures/plans/fail_on_timeout.yaml +20 -0
- data/spec/fixtures/plans/hello_world.yaml +34 -0
- data/spec/fixtures/plans/non_existing_node.yaml +26 -0
- data/spec/fixtures/plans/test_role_variable.yaml +29 -0
- data/spec/fixtures/puppet/Puppetfile +8 -0
- data/spec/fixtures/puppet/Puppetfile.lock +57 -0
- data/spec/fixtures/puppet/hiera.yaml +6 -0
- data/spec/fixtures/puppet/manifests/site.pp +52 -0
- data/spec/fixtures/test_configuration.yaml +54 -0
- data/spec/fixtures/test_credentials.yaml +11 -0
- data/spec/fixtures/test_deloyed_file.txt +5 -0
- data/spec/fixtures/test_infrastructure.yaml +12 -0
- data/spec/fixtures/test_nodes.yaml +45 -0
- data/spec/fixtures/testenv_plan.yaml +159 -0
- data/spec/integration/dopi/addrun_spec.rb +31 -0
- data/spec/integration/dopi/cli/command_run_spec.rb +38 -0
- data/spec/integration/dopi/cli/global_options_spec.rb +128 -0
- data/spec/integration/dopi/command_spec.rb +66 -0
- data/spec/integration/dopi/fail_check_plans/file_exists_fails.yaml +38 -0
- data/spec/integration/dopi/fail_check_plans/output_parser.yaml +39 -0
- data/spec/integration/dopi/fail_check_plans/powershell_fail.yaml +25 -0
- data/spec/integration/dopi/fail_check_plans/timeout.yaml +29 -0
- data/spec/integration/dopi/fail_check_plans/verify_commands.yaml +33 -0
- data/spec/integration/dopi/failplan.rb +27 -0
- data/spec/integration/dopi/plan.rb +27 -0
- data/spec/integration/dopi/plans/dummy.yaml +29 -0
- data/spec/integration/dopi/plans/max_per_role.yaml +55 -0
- data/spec/integration/dopi/plans/no_timeout.yaml +29 -0
- data/spec/integration/dopi/plans/node_and_role_patterns.yaml +58 -0
- data/spec/integration/dopi/plans/node_by_config.yaml +116 -0
- data/spec/integration/dopi/plans/plugin_defaults.yaml +86 -0
- data/spec/integration/dopi/plans/plugins/mco/rpc.yaml +33 -0
- data/spec/integration/dopi/plans/plugins/ssh/custom.yaml +97 -0
- data/spec/integration/dopi/plans/plugins/ssh/file_contains.yaml +51 -0
- data/spec/integration/dopi/plans/plugins/ssh/file_deploy.yaml +82 -0
- data/spec/integration/dopi/plans/plugins/ssh/file_exists.yaml +69 -0
- data/spec/integration/dopi/plans/plugins/ssh/file_replace.yaml +55 -0
- data/spec/integration/dopi/plans/plugins/ssh/puppet_agent_run.yaml +45 -0
- data/spec/integration/dopi/plans/plugins/ssh/reboot.yaml +43 -0
- data/spec/integration/dopi/plans/plugins/ssh/wait_for_login.yaml +45 -0
- data/spec/integration/dopi/plans/plugins/winrm/cmd.yaml +39 -0
- data/spec/integration/dopi/plans/plugins/winrm/file_contains.yaml +51 -0
- data/spec/integration/dopi/plans/plugins/winrm/file_exists.yaml +69 -0
- data/spec/integration/dopi/plans/plugins/winrm/reboot.yaml +31 -0
- data/spec/integration/dopi/plans/resolve_roles_on_validate.yaml +23 -0
- data/spec/integration/dopi/plans/ssh_parallel.yaml +37 -0
- data/spec/integration/dopi/plans/verify_commands.yaml +49 -0
- data/spec/spec_helper.rb +104 -0
- data/spec/unit/dopi/command/custom_spec.rb +58 -0
- data/spec/unit/dopi/command/mco/rpc_spec.rb +157 -0
- data/spec/unit/dopi/command/ssh/custom_spec.rb +30 -0
- data/spec/unit/dopi/command/ssh/file_deploy_spec.rb +42 -0
- data/spec/unit/dopi/command/ssh/file_replace_spec.rb +35 -0
- data/spec/unit/dopi/command_parser/credentials_spec.rb +53 -0
- data/spec/unit/dopi/command_parser/exit_code_spec.rb +63 -0
- data/spec/unit/dopi/command_parser/output_spec.rb +129 -0
- data/spec/unit/dopi/command_spec.rb +14 -0
- data/spec/unit/dopi/connector/winrm_spec.rb +111 -0
- data/spec/unit/dopi/node_spec.rb +24 -0
- data/spec/unit/dopi/plan_spec.rb +31 -0
- data/spec/unit/dopi/state_spec.rb +109 -0
- data/spec/unit/dopi/step_spec.rb +13 -0
- metadata +448 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# This site.pp is the entry point for puppet in the testenv
|
|
2
|
+
# It contains some workarounds to help with problems in the
|
|
3
|
+
# used modules
|
|
4
|
+
|
|
5
|
+
$role = hiera('role')
|
|
6
|
+
|
|
7
|
+
class base {
|
|
8
|
+
hiera_include('classes')
|
|
9
|
+
|
|
10
|
+
file{'/usr/libexec/mcollective/': ensure => directory}
|
|
11
|
+
file{'/usr/libexec/mcollective/mcollective': ensure => directory}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
node default {
|
|
15
|
+
include base
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
node 'puppetmaster.example.com' {
|
|
19
|
+
include base
|
|
20
|
+
|
|
21
|
+
file{'/etc/puppet/autosign.conf':
|
|
22
|
+
content => "*.example.com\n",
|
|
23
|
+
mode => '0664',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#file{'/etc/puppet/environments/production/manifests/': ensure => directory }
|
|
27
|
+
file{'/etc/puppet/environments/production/manifests/site.pp':
|
|
28
|
+
ensure => symlink,
|
|
29
|
+
target => '/etc/puppet/manifests/site.pp',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# This are some fixes because there is not realy a working
|
|
35
|
+
# mcollective module for centos at the moment
|
|
36
|
+
node 'broker.example.com' {
|
|
37
|
+
include base
|
|
38
|
+
|
|
39
|
+
# FIX for activemq module
|
|
40
|
+
file{'/etc/activemq/': ensure => directory }
|
|
41
|
+
file{'/etc/activemq/instances-available': ensure => directory }
|
|
42
|
+
file{'/etc/activemq/instances-enabled': ensure => directory }
|
|
43
|
+
|
|
44
|
+
# This is probably needed because we use an debian module or something
|
|
45
|
+
file{'/etc/activemq/activemq.xml':
|
|
46
|
+
source => 'file:///etc/activemq/instances-available/mcollective/activemq.xml',
|
|
47
|
+
require => File['/etc/activemq/instances-available/mcollective/activemq.xml'],
|
|
48
|
+
notify => Service['activemq'],
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Class['java'] -> Class['activemq']
|
|
52
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
configuration:
|
|
2
|
+
nodes:
|
|
3
|
+
'puppetmaster.example.com':
|
|
4
|
+
role: 'puppetmaster'
|
|
5
|
+
'broker.example.com':
|
|
6
|
+
role: 'mcollective_broker'
|
|
7
|
+
'windows01.example.com':
|
|
8
|
+
os: 'windows'
|
|
9
|
+
roles:
|
|
10
|
+
'puppetmaster':
|
|
11
|
+
classes:
|
|
12
|
+
- 'foreman'
|
|
13
|
+
- 'puppet'
|
|
14
|
+
foreman::foreman_url: "%{hiera('::fqdn')}"
|
|
15
|
+
foreman::unattended: 'false'
|
|
16
|
+
foreman::authentication: 'false'
|
|
17
|
+
puppet::server: true
|
|
18
|
+
puppet::autosign: '/usr/local/bin/dop-puppet-autosign'
|
|
19
|
+
puppet::autosign_mode: 'script'
|
|
20
|
+
puppet::server_foreman: true
|
|
21
|
+
puppet::server_rttendedeports: 'store'
|
|
22
|
+
puppet::server_external_nodes: ''
|
|
23
|
+
'mcollective_broker':
|
|
24
|
+
classes:
|
|
25
|
+
- 'java'
|
|
26
|
+
- 'activemq'
|
|
27
|
+
java::distribution: 'jdk'
|
|
28
|
+
java::version: 'latest'
|
|
29
|
+
activemq::instances:
|
|
30
|
+
'mcollective':
|
|
31
|
+
stomp_nio_port: "%{hiera('mcollective::broker_port')}"
|
|
32
|
+
user_name: "%{hiera('mcollective::broker_user')}"
|
|
33
|
+
user_password: "%{hiera('mcollective::broker_password')}"
|
|
34
|
+
defaults:
|
|
35
|
+
classes:
|
|
36
|
+
- 'firewall'
|
|
37
|
+
- 'puppet'
|
|
38
|
+
- 'mcollective'
|
|
39
|
+
role: 'base'
|
|
40
|
+
os: 'linux'
|
|
41
|
+
firewall::ensure: 'stopped'
|
|
42
|
+
puppet::puppetmaster: 'puppetmaster.example.com'
|
|
43
|
+
puppet::runmode: 'none'
|
|
44
|
+
mcollective::use_node: true
|
|
45
|
+
mcollective::connector: 'activemq'
|
|
46
|
+
mcollective::broker_host: 'broker.example.com'
|
|
47
|
+
mcollective::broker_port: 61614
|
|
48
|
+
mcollective::broker_ssl: 'false'
|
|
49
|
+
mcollective::broker_user: 'mcollective'
|
|
50
|
+
mcollective::broker_password: 'vagrant'
|
|
51
|
+
mcollective::security_provider: 'psk'
|
|
52
|
+
mcollective::security_secret: 'vagrant'
|
|
53
|
+
|
|
54
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
nodes:
|
|
2
|
+
'puppetmaster.example.com':
|
|
3
|
+
infrastructure: 'vagrant'
|
|
4
|
+
image: 'puppetlabs/centos-7.0-64-nocm'
|
|
5
|
+
interfaces:
|
|
6
|
+
'eth0':
|
|
7
|
+
network: 'vboxnet0'
|
|
8
|
+
ip: '192.168.56.101'
|
|
9
|
+
'broker.example.com':
|
|
10
|
+
infrastructure: 'vagrant'
|
|
11
|
+
image: 'puppetlabs/centos-7.0-64-nocm'
|
|
12
|
+
interfaces:
|
|
13
|
+
'eth0':
|
|
14
|
+
network: 'vboxnet0'
|
|
15
|
+
ip: '192.168.56.102'
|
|
16
|
+
'linux01.example.com':
|
|
17
|
+
infrastructure: 'vagrant'
|
|
18
|
+
image: 'puppetlabs/centos-7.0-64-nocm'
|
|
19
|
+
interfaces:
|
|
20
|
+
'eth0':
|
|
21
|
+
network: 'vboxnet0'
|
|
22
|
+
ip: '192.168.56.103'
|
|
23
|
+
'linux02.example.com':
|
|
24
|
+
infrastructure: 'vagrant'
|
|
25
|
+
image: 'puppetlabs/centos-7.0-64-nocm'
|
|
26
|
+
interfaces:
|
|
27
|
+
'eth0':
|
|
28
|
+
network: 'vboxnet0'
|
|
29
|
+
ip: '192.168.56.104'
|
|
30
|
+
'linux03.example.com':
|
|
31
|
+
infrastructure: 'vagrant'
|
|
32
|
+
image: 'puppetlabs/centos-7.0-64-nocm'
|
|
33
|
+
interfaces:
|
|
34
|
+
'eth0':
|
|
35
|
+
network: 'vboxnet0'
|
|
36
|
+
ip: '192.168.56.105'
|
|
37
|
+
'windows01.example.com':
|
|
38
|
+
infrastructure: 'vagrant'
|
|
39
|
+
image: 'opentable/win-2012r2-standard-amd64-nocm'
|
|
40
|
+
interfaces:
|
|
41
|
+
'eth0':
|
|
42
|
+
network: 'vboxnet0'
|
|
43
|
+
ip: '192.168.56.106'
|
|
44
|
+
|
|
45
|
+
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# This dop plan will setup the test environment for DOPi
|
|
2
|
+
#
|
|
3
|
+
# For now we will just use a bermetal type and vagrant
|
|
4
|
+
# this should one day be replaced with dopv and some
|
|
5
|
+
# local endpoint to create the machines.
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
name: 'build_dop_test_environment'
|
|
9
|
+
max_in_flight: -1
|
|
10
|
+
|
|
11
|
+
include: 'test_infrastructure.yaml'
|
|
12
|
+
include: 'test_nodes.yaml'
|
|
13
|
+
include: 'test_credentials.yaml'
|
|
14
|
+
include: 'test_configuration.yaml'
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: 'Configure ssh credentials and wait until all the linux machines are online'
|
|
18
|
+
nodes_by_config: {os: 'linux'}
|
|
19
|
+
set_plugin_defaults: [{plugins: '/^ssh/', credentials: 'linux_login'}]
|
|
20
|
+
command: 'ssh/wait_for_login'
|
|
21
|
+
|
|
22
|
+
- name: 'Configure winrm credentials and wait until all the windows machines are online'
|
|
23
|
+
nodes_by_config: {os: 'windows'}
|
|
24
|
+
set_plugin_defaults: [{plugins: '/^winrm/', credentials: 'windows_login'}]
|
|
25
|
+
command: 'winrm/wait_for_login'
|
|
26
|
+
|
|
27
|
+
- name: 'install the puppetlabs repository'
|
|
28
|
+
nodes_by_config: {os: 'linux'}
|
|
29
|
+
command:
|
|
30
|
+
verify_commands:
|
|
31
|
+
- plugin: 'ssh/file_exists'
|
|
32
|
+
file: '/etc/yum.repos.d/puppetlabs.repo'
|
|
33
|
+
plugin: 'ssh/custom'
|
|
34
|
+
exec: 'rpm'
|
|
35
|
+
arguments: '-ivh https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm'
|
|
36
|
+
|
|
37
|
+
- name: 'install puppet on all the nodes'
|
|
38
|
+
nodes_by_config: {os: 'linux'}
|
|
39
|
+
command:
|
|
40
|
+
verify_commands:
|
|
41
|
+
- plugin: 'ssh/file_exists'
|
|
42
|
+
file: '/usr/bin/puppet'
|
|
43
|
+
plugin: 'ssh/custom'
|
|
44
|
+
exec: 'yum'
|
|
45
|
+
arguments: 'install -y puppet'
|
|
46
|
+
|
|
47
|
+
- name: 'copy the puppet configuration to the right place'
|
|
48
|
+
roles: 'puppetmaster'
|
|
49
|
+
command:
|
|
50
|
+
plugin: 'ssh/custom'
|
|
51
|
+
exec: 'cp'
|
|
52
|
+
arguments: '-r /vagrant/spec/fixtures/puppet/* /etc/puppet/'
|
|
53
|
+
|
|
54
|
+
- name: 'Install all the needed packages on the puppetmaster'
|
|
55
|
+
roles: 'puppetmaster'
|
|
56
|
+
command:
|
|
57
|
+
verify_commands:
|
|
58
|
+
- plugin: 'ssh/file_exists'
|
|
59
|
+
file: '/usr/bin/rake'
|
|
60
|
+
- plugin: 'ssh/file_exists'
|
|
61
|
+
file: '/usr/bin/bundle'
|
|
62
|
+
- plugin: 'ssh/file_exists'
|
|
63
|
+
file: '/usr/bin/git'
|
|
64
|
+
- plugin: 'ssh/file_exists'
|
|
65
|
+
file: '/usr/include/ruby.h'
|
|
66
|
+
plugin: 'ssh/custom'
|
|
67
|
+
exec: 'yum'
|
|
68
|
+
arguments: 'install -y rubygem-rake rubygem-bundler git ruby-devel'
|
|
69
|
+
|
|
70
|
+
- name: 'Install librarian-puppet'
|
|
71
|
+
roles: 'puppetmaster'
|
|
72
|
+
command:
|
|
73
|
+
verify_commands:
|
|
74
|
+
- plugin: 'ssh/file_exists'
|
|
75
|
+
file: '/usr/local/bin/librarian-puppet'
|
|
76
|
+
plugin: 'ssh/custom'
|
|
77
|
+
exec: 'gem'
|
|
78
|
+
arguments: 'install librarian-puppet'
|
|
79
|
+
|
|
80
|
+
- name: 'Install all the puppet modules'
|
|
81
|
+
roles: 'puppetmaster'
|
|
82
|
+
command:
|
|
83
|
+
verify_commands:
|
|
84
|
+
- plugin: 'ssh/file_exists'
|
|
85
|
+
file: '/etc/puppet/.librarian/puppet/config'
|
|
86
|
+
plugin: 'ssh/custom'
|
|
87
|
+
exec: 'librarian-puppet'
|
|
88
|
+
arguments: 'install'
|
|
89
|
+
env: {LIBRARIAN_PUPPET_PUPPETFILE: '/etc/puppet/Puppetfile'}
|
|
90
|
+
|
|
91
|
+
- name: 'Install dop_common for the puppetmaster'
|
|
92
|
+
roles: 'puppetmaster'
|
|
93
|
+
command:
|
|
94
|
+
verify_commands:
|
|
95
|
+
- plugin: 'ssh/custom'
|
|
96
|
+
exec: 'gem list | grep dop_common'
|
|
97
|
+
plugin: 'ssh/custom'
|
|
98
|
+
exec: 'cd /vagrant/vendor/cache/dop_common-*/ && gem build dop_common.gemspec && gem install dop_common*.gem'
|
|
99
|
+
|
|
100
|
+
- name: 'Install DOPi so we can add the plan'
|
|
101
|
+
roles: 'puppetmaster'
|
|
102
|
+
command:
|
|
103
|
+
verify_commands:
|
|
104
|
+
- plugin: 'ssh/file_exists'
|
|
105
|
+
file: '/vagrant/.bundle/config'
|
|
106
|
+
plugin: 'ssh/custom'
|
|
107
|
+
exec: 'bundle'
|
|
108
|
+
arguments: 'install --local'
|
|
109
|
+
env: {BUNDLE_GEMFILE: '/vagrant/Gemfile'}
|
|
110
|
+
|
|
111
|
+
- name: 'Add deployment plan with hiera data to the plan cache'
|
|
112
|
+
roles: 'puppetmaster'
|
|
113
|
+
command:
|
|
114
|
+
verify_commands:
|
|
115
|
+
- plugin: 'ssh/file_exists'
|
|
116
|
+
file: '/var/lib/dop/plans/build_dop_test_environment.yaml'
|
|
117
|
+
plugin: 'ssh/custom'
|
|
118
|
+
exec: 'bundle'
|
|
119
|
+
arguments: 'exec dopi add /vagrant/spec/fixtures/testenv_plan.yaml'
|
|
120
|
+
env: {BUNDLE_GEMFILE: '/vagrant/Gemfile'}
|
|
121
|
+
|
|
122
|
+
- name: 'Run puppet on puppetmaster'
|
|
123
|
+
roles: 'puppetmaster'
|
|
124
|
+
command:
|
|
125
|
+
verify_commands:
|
|
126
|
+
- plugin: 'ssh/file_exists'
|
|
127
|
+
file: '/etc/httpd/conf.d/25-puppet.conf'
|
|
128
|
+
plugin: 'ssh/custom'
|
|
129
|
+
exec: 'puppet'
|
|
130
|
+
arguments: 'apply /etc/puppet/manifests/site.pp'
|
|
131
|
+
|
|
132
|
+
- name: 'Add puppetmaster to all hosts files'
|
|
133
|
+
nodes_by_config: {os: 'linux'}
|
|
134
|
+
command:
|
|
135
|
+
verify_commands:
|
|
136
|
+
- plugin: 'ssh/file_contains'
|
|
137
|
+
file: '/etc/hosts'
|
|
138
|
+
pattern: 'puppetmaster.example.com'
|
|
139
|
+
plugin: 'ssh/custom'
|
|
140
|
+
exec: "echo"
|
|
141
|
+
arguments: '"192.168.56.101 puppetmaster.example.com puppetmaster" >> /etc/hosts'
|
|
142
|
+
|
|
143
|
+
- name: 'Add broker to all hosts files'
|
|
144
|
+
nodes_by_config: {os: 'linux'}
|
|
145
|
+
command:
|
|
146
|
+
verify_commands:
|
|
147
|
+
- plugin: 'ssh/file_contains'
|
|
148
|
+
file: '/etc/hosts'
|
|
149
|
+
pattern: 'broker.example.com'
|
|
150
|
+
plugin: 'ssh/custom'
|
|
151
|
+
exec: "echo"
|
|
152
|
+
arguments: '"192.168.56.102 broker.example.com broker" >> /etc/hosts'
|
|
153
|
+
|
|
154
|
+
- name: 'Run puppet on the rest of the linux nodes'
|
|
155
|
+
nodes_by_config: {os: 'linux'}
|
|
156
|
+
exclude_roles: 'puppetmaster'
|
|
157
|
+
command:
|
|
158
|
+
plugin: 'ssh/puppet_agent_run'
|
|
159
|
+
arguments: '--server puppetmaster.example.com'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
# Try running the plan when it is added (persisted to disk) and loaded again
|
|
4
|
+
# before running.
|
|
5
|
+
|
|
6
|
+
DopCommon.config.mco_config = 'spec/fixtures/mco_client.cfg'
|
|
7
|
+
DopCommon.config.hiera_yaml = 'spec/fixtures/puppet/hiera.yaml'
|
|
8
|
+
|
|
9
|
+
plan_file = "spec/integration/dopi/plans/dummy.yaml"
|
|
10
|
+
plan_name = nil
|
|
11
|
+
plan = nil
|
|
12
|
+
|
|
13
|
+
describe 'running an added plan' do
|
|
14
|
+
context 'in temp directory' do
|
|
15
|
+
Dir.mktmpdir do |tmp|
|
|
16
|
+
DopCommon.config.plan_store_dir = tmp
|
|
17
|
+
it 'add plan to store' do
|
|
18
|
+
plan_name = Dopi.add(plan_file)
|
|
19
|
+
end
|
|
20
|
+
it 'load plan from store' do
|
|
21
|
+
plan = Dopi.show(plan_name)
|
|
22
|
+
end
|
|
23
|
+
it 'run loaded plan' do
|
|
24
|
+
Dopi.run(plan_name)
|
|
25
|
+
end
|
|
26
|
+
it 'remove plan from store' do
|
|
27
|
+
Dopi.remove(plan_name)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'command_run' do
|
|
4
|
+
fixture_file 'puppet'
|
|
5
|
+
fixture_file 'plans'
|
|
6
|
+
|
|
7
|
+
describe 'run exit code' do
|
|
8
|
+
before :each do
|
|
9
|
+
Dopi.add("spec/fixtures/plans/#{plan_name}.yaml")
|
|
10
|
+
end
|
|
11
|
+
after :each do
|
|
12
|
+
Dopi.remove(plan_name, true)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'plan run will be successful' do
|
|
16
|
+
let(:plan_name) { 'hello_world' }
|
|
17
|
+
command 'dopi --verbosity INFO run hello_world'
|
|
18
|
+
its(:exitstatus) { is_expected.to eq 0 }
|
|
19
|
+
end
|
|
20
|
+
context 'plan will fail on command timeout' do
|
|
21
|
+
let(:plan_name) { 'fail_on_timeout' }
|
|
22
|
+
command 'dopi --verbosity INFO run fail_on_timeout', :allow_error => true
|
|
23
|
+
its(:exitstatus) { is_expected.to_not eq 0 }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'oneshot exit code' do
|
|
28
|
+
context 'plan run will be successful' do
|
|
29
|
+
command "dopi --verbosity INFO oneshot hello_world.yaml"
|
|
30
|
+
its(:exitstatus) { is_expected.to eq 0 }
|
|
31
|
+
end
|
|
32
|
+
context 'plan will fail on command timeout' do
|
|
33
|
+
command "dopi --verbosity INFO oneshot fail_on_timeout.yaml", :allow_error => true
|
|
34
|
+
its(:exitstatus) { is_expected.to_not eq 0 }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'global cli options' do
|
|
4
|
+
fixture_file 'puppet'
|
|
5
|
+
fixture_file 'plans'
|
|
6
|
+
|
|
7
|
+
describe 'connection_check_timeout' do
|
|
8
|
+
pending
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'facts_dir' do
|
|
12
|
+
pending # This option should be removed
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'hiera_yaml' do
|
|
16
|
+
context 'Invalid hiera.yaml' do
|
|
17
|
+
command 'dopi --hiera_yaml ./nothiera.yaml oneshot test_role_variable.yaml', :allow_error => true
|
|
18
|
+
its(:stdout) {is_expected.to include 'hiera.yaml not found! Using empty config'}
|
|
19
|
+
end
|
|
20
|
+
context 'Valid hiera.yaml' do
|
|
21
|
+
command 'dopi --hiera_yaml ./hiera.yaml oneshot test_role_variable.yaml', :allow_error => true
|
|
22
|
+
its(:stdout) {is_expected.not_to include 'hiera.yaml not found! Using empty config'}
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe 'load_facts' do
|
|
27
|
+
pending # This option should be removed
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '--log_dir' do
|
|
31
|
+
before :each do
|
|
32
|
+
command "dopi --log_dir ./mylog oneshot hello_world.yaml"
|
|
33
|
+
end
|
|
34
|
+
it 'should create the directory' do
|
|
35
|
+
expect(Dir.entries(temp_path)).to include 'mylog'
|
|
36
|
+
end
|
|
37
|
+
it 'should write to the log file in the directory' do
|
|
38
|
+
log_file = File.join(temp_path, 'mylog', 'dopi.log')
|
|
39
|
+
expect(File.read(log_file)).to include
|
|
40
|
+
"Step 'write hello world' successfully finished."
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe 'log_level' do
|
|
45
|
+
context 'INFO' do
|
|
46
|
+
it 'should not contain debug output in the log file' do
|
|
47
|
+
command "dopi --log_dir ./mylog --log_level INFO oneshot hello_world.yaml"
|
|
48
|
+
log_file = File.join(temp_path, 'mylog', 'dopi.log')
|
|
49
|
+
expect(File.read(log_file)).not_to include
|
|
50
|
+
'Executing echo "hello world"'
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
context 'DEBUG' do
|
|
54
|
+
it 'should contain debug output in the log file' do
|
|
55
|
+
command "dopi --log_dir ./mylog --log_level DEBUG oneshot hello_world.yaml"
|
|
56
|
+
log_file = File.join(temp_path, 'mylog', 'dopi.log')
|
|
57
|
+
expect(File.read(log_file)).to include
|
|
58
|
+
'Executing echo "hello world"'
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe 'mco_config' do
|
|
64
|
+
pending
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe 'mco_dopi_logger' do
|
|
68
|
+
pending
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe 'plan_store_dir' do
|
|
72
|
+
before :each do
|
|
73
|
+
command "dopi --plan_store_dir ./plan_store add hello_world.yaml"
|
|
74
|
+
end
|
|
75
|
+
it 'should create the directory' do
|
|
76
|
+
expect(Dir.entries(temp_path)).to include 'plan_store'
|
|
77
|
+
end
|
|
78
|
+
it 'should add the plan to the plan_store' do
|
|
79
|
+
stored_plan = File.join(temp_path, 'plan_store', 'hello_world')
|
|
80
|
+
expect(File.exists?(stored_plan)).to be true
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe 'role_default' do
|
|
85
|
+
context 'role_default is not set' do
|
|
86
|
+
command 'dopi oneshot test_role_variable.yaml', :allow_error => true
|
|
87
|
+
its(:stdout) {is_expected.to include 'No role found for linux01.example.com'}
|
|
88
|
+
end
|
|
89
|
+
context 'role_default is set' do
|
|
90
|
+
command 'dopi --role_default testnode oneshot test_role_variable.yaml'
|
|
91
|
+
its(:stdout) {is_expected.to include "Step 'write hello world' successfully finished."}
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe 'role_variable' do
|
|
96
|
+
context 'role_variable is not set' do
|
|
97
|
+
command 'dopi --hiera_yaml hiera.yaml oneshot test_role_variable.yaml', :allow_error => true
|
|
98
|
+
its(:stdout) {is_expected.to include 'No role found for linux01.example.com'}
|
|
99
|
+
end
|
|
100
|
+
context 'role_default is set' do
|
|
101
|
+
command 'dopi --hiera_yaml hiera.yaml --role_variable test_role oneshot test_role_variable.yaml'
|
|
102
|
+
its(:stdout) {is_expected.to include "Step 'write hello world' successfully finished."}
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe 'use_hiera' do
|
|
107
|
+
context 'default behaviour' do
|
|
108
|
+
command 'dopi --hiera_yaml ./nothiera.yaml oneshot test_role_variable.yaml', :allow_error => true
|
|
109
|
+
its(:stdout) {is_expected.to include 'hiera.yaml not found! Using empty config'}
|
|
110
|
+
end
|
|
111
|
+
context 'Disable hiera' do
|
|
112
|
+
command 'dopi --no-use_hiera oneshot test_role_variable.yaml', :allow_error => true
|
|
113
|
+
its(:stdout) {is_expected.not_to include 'hiera.yaml not found! Using empty config'}
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
describe '--verbosity' do
|
|
118
|
+
context 'INFO' do
|
|
119
|
+
command "dopi --verbosity INFO oneshot hello_world.yaml"
|
|
120
|
+
its(:stdout) {is_expected.not_to include 'Executing echo "hello world"'}
|
|
121
|
+
end
|
|
122
|
+
context 'DEBUG' do
|
|
123
|
+
command "dopi --verbosity DEBUG oneshot hello_world.yaml"
|
|
124
|
+
its(:stdout) {is_expected.to include 'Executing echo "hello world"'}
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
DopCommon.config.mco_config = 'spec/fixtures/mco_client.cfg'
|
|
4
|
+
DopCommon.config.hiera_yaml = 'spec/fixtures/puppet/hiera.yaml'
|
|
5
|
+
|
|
6
|
+
describe 'Basic integration test built from plan files' do
|
|
7
|
+
|
|
8
|
+
# Create plugin tests from plugin test yaml files
|
|
9
|
+
# and check if they run successfully
|
|
10
|
+
Dir['spec/integration/dopi/plans/**/*.yaml'].each do |plan_file|
|
|
11
|
+
describe plan_file do
|
|
12
|
+
plan_parser = DopCommon::Plan.new(YAML.load_file(plan_file))
|
|
13
|
+
plan = Dopi::Plan.new(plan_parser)
|
|
14
|
+
node_names = plan.nodes.map{|n| n.name}
|
|
15
|
+
plan.instance_variable_set(:@context_logger, DopCommon::ThreadContextLogger.new('/tmp/dopi_test', node_names))
|
|
16
|
+
it "is a valid plan file" do
|
|
17
|
+
expect(plan.valid?).to be true
|
|
18
|
+
end
|
|
19
|
+
plan.step_sets.each do |step_set|
|
|
20
|
+
step_set.steps.each do |step|
|
|
21
|
+
it "successfully runs the step: '#{step.name}'" do
|
|
22
|
+
step.run({:run_for_nodes => :all, :noop => false})
|
|
23
|
+
expect(step.state).to be :done
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Create plugin tests from plugin test yaml files
|
|
31
|
+
# and check if they fail
|
|
32
|
+
Dir['spec/integration/dopi/fail_check_plans/**/*.yaml'].each do |plan_file|
|
|
33
|
+
describe plan_file do
|
|
34
|
+
plan_parser = DopCommon::Plan.new(YAML.load_file(plan_file))
|
|
35
|
+
plan = Dopi::Plan.new(plan_parser)
|
|
36
|
+
node_names = plan.nodes.map{|n| n.name}
|
|
37
|
+
plan.instance_variable_set(:@context_logger, DopCommon::ThreadContextLogger.new('/tmp/dopi_test', node_names))
|
|
38
|
+
it "is a valid plan file" do
|
|
39
|
+
expect(plan.valid?).to be true
|
|
40
|
+
end
|
|
41
|
+
plan.step_sets.each do |step_set|
|
|
42
|
+
step_set.steps.each do |step|
|
|
43
|
+
it "successfully runs the step: '#{step.name}'" do
|
|
44
|
+
step.run({:run_for_nodes => :all, :noop => false})
|
|
45
|
+
expect(step.state).to be :failed
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Create plugin tests from plugin test yaml files
|
|
53
|
+
# and check if they are not valid
|
|
54
|
+
Dir['spec/integration/dopi/invalid_plans/**/*.yaml'].each do |plan_file|
|
|
55
|
+
describe plan_file do
|
|
56
|
+
plan_parser = DopCommon::Plan.new(YAML.load_file(plan_file))
|
|
57
|
+
plan = Dopi::Plan.new(plan_parser)
|
|
58
|
+
node_names = plan.nodes.map{|n| n.name}
|
|
59
|
+
plan.instance_variable_set(:@context_logger, DopCommon::ThreadContextLogger.new('/tmp/dopi_test', node_names))
|
|
60
|
+
it "is not a valid plan file" do
|
|
61
|
+
expect(plan.valid?).to be false
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: 'test_powershell_exitcode_handling'
|
|
2
|
+
max_in_flight: 1
|
|
3
|
+
|
|
4
|
+
infrastructures:
|
|
5
|
+
'test':
|
|
6
|
+
type: 'baremetal'
|
|
7
|
+
|
|
8
|
+
nodes:
|
|
9
|
+
'windows01.example.com':
|
|
10
|
+
infrastructure: 'test'
|
|
11
|
+
'linux01.example.com':
|
|
12
|
+
infrastructure: 'test'
|
|
13
|
+
|
|
14
|
+
credentials:
|
|
15
|
+
'windows_login':
|
|
16
|
+
type: 'username_password'
|
|
17
|
+
username: 'administrator'
|
|
18
|
+
password: 'vagrant'
|
|
19
|
+
'linux_login':
|
|
20
|
+
type: 'username_password'
|
|
21
|
+
username: 'root'
|
|
22
|
+
password: 'puppet'
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
|
|
26
|
+
- name: 'Check if the plugin fails for the windows command'
|
|
27
|
+
nodes: 'windows01.example.com'
|
|
28
|
+
command:
|
|
29
|
+
plugin: 'winrm/file_exists'
|
|
30
|
+
credentials: 'windows_login'
|
|
31
|
+
file: 'C:\nonexistingfile.txt'
|
|
32
|
+
|
|
33
|
+
- name: 'Check if the plugin fails for the linux command'
|
|
34
|
+
nodes: 'linux01.example.com'
|
|
35
|
+
command:
|
|
36
|
+
plugin: 'ssh/file_exists'
|
|
37
|
+
credentials: 'linux_login'
|
|
38
|
+
file: '/nonexistingfile.txt'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: 'fail_test_for_ouptut_parser'
|
|
2
|
+
|
|
3
|
+
infrastructures:
|
|
4
|
+
'test':
|
|
5
|
+
type: 'baremetal'
|
|
6
|
+
|
|
7
|
+
nodes:
|
|
8
|
+
'linux01.example.com':
|
|
9
|
+
infrastructure: 'test'
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
|
|
13
|
+
#
|
|
14
|
+
# Check if the parser is working as intended
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
- name: 'Check if the output parser can catch an error'
|
|
18
|
+
nodes: 'all'
|
|
19
|
+
command:
|
|
20
|
+
plugin: 'custom'
|
|
21
|
+
exec: 'echo'
|
|
22
|
+
arguments: '"Error: this is a simulated error"'
|
|
23
|
+
parse_output:
|
|
24
|
+
error:
|
|
25
|
+
- '^Error:'
|
|
26
|
+
|
|
27
|
+
- name: 'Check if the output parser can catch a warning'
|
|
28
|
+
nodes: 'all'
|
|
29
|
+
command:
|
|
30
|
+
plugin: 'custom'
|
|
31
|
+
exec: 'echo'
|
|
32
|
+
arguments: '"Warning: This is a simulated warning"'
|
|
33
|
+
fail_on_warning: true
|
|
34
|
+
parse_output:
|
|
35
|
+
warning:
|
|
36
|
+
- '^Warning:'
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|