ref_arch_setup 0.0.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,6 @@ module RefArchSetup
2
2
  # Module for holding version info
3
3
  module Version
4
4
  # Version number
5
- STRING = "0.0.1".freeze
5
+ STRING = "0.5.0".freeze
6
6
  end
7
7
  end
@@ -0,0 +1,13 @@
1
+ {
2
+ "description": "A task to download the specified PE tarball",
3
+ "parameters": {
4
+ "url": {
5
+ "description": "The URL for the specified tarball",
6
+ "type": "Pattern['https?://.*\.(tar|tar\.gz)$']"
7
+ },
8
+ "destination": {
9
+ "description": "The folder where the tarball should be saved",
10
+ "type": "Optional[String[1]]"
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Download PE Tarball:
4
+ # This is a script-based task as the target node may not have Ruby installed.
5
+ # Provide the URL and optionally an existing destination directory (the default is /tmp/ref_arch_setup).
6
+ # Run the task as per the following examples:
7
+ #
8
+ # Localhost with default destination -
9
+ # bolt task run ref_arch_setup::download_pe_tarball url=http://test.net/test.gz --modulepath ./modules --nodes localhost
10
+ #
11
+ # Remote node as root user with specified destination -
12
+ # bolt task run ref_arch_setup::download_pe_tarball url=http://test.net/test.gz destination=/tmp/ras --modulepath ./modules --nodes tjsss144r6ouvhc --user root
13
+
14
+ URL=$PT_url
15
+ DESTINATION=${PT_destination:-/tmp/ref_arch_setup}
16
+ FILENAME=$(basename $PT_url)
17
+ DESTINATION_PATH=$DESTINATION/$FILENAME
18
+
19
+ echo URL: $URL
20
+ echo Destination: $DESTINATION
21
+ echo Filename: $FILENAME
22
+ echo
23
+
24
+ # check for the directory; attempt to create if it doesn't exist
25
+ if [ -d "$DESTINATION" ]; then
26
+ echo "Destination directory exists; proceeding"
27
+ else
28
+ echo "Destination directory does not exist; attempting to create"
29
+ mkdir -p $DESTINATION
30
+ fi
31
+
32
+ # check for the directory again; proceed if it exists, otherwise exit
33
+ if [ -d "$DESTINATION" ]; then
34
+ echo Downloading $URL to $DESTINATION_PATH
35
+
36
+ # download and check for failure
37
+ if curl -f -L -o $DESTINATION_PATH $URL ; then
38
+ echo "Download complete"
39
+ exit 0
40
+ else
41
+ echo "Download failed; exiting"
42
+ exit 1
43
+ fi
44
+
45
+ else
46
+ echo "Destination directory does not exist and could not be created; exiting"
47
+ exit 1
48
+ fi
@@ -0,0 +1,10 @@
1
+ {
2
+ "description": "Generates a PE.conf file at ./tmp/pe.conf",
3
+
4
+ "parameters": {
5
+ "console_password": {
6
+ "description": "The initial console password for the puppet admin user",
7
+ "type": "String[1]"
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,128 @@
1
+ #!/opt/puppetlabs/puppet/bin/ruby
2
+ require "fileutils"
3
+
4
+ # rubocop:disable Style/FormatStringToken
5
+ pe_conf = <<~PE_CONF
6
+ #----------------------------------------------------------------------------
7
+ # Puppet Enterprise installer configuration file
8
+ # https://docs.puppet.com/pe/latest/install_pe_conf_param.html
9
+ #
10
+ # Format: Hocon
11
+ # https://docs.puppet.com/pe/latest/config_hocon.html
12
+ #----------------------------------------------------------------------------
13
+ {
14
+ #--------------------------------------------------------------------------
15
+ # ⚠️ REQUIRED FOR INSTALLATION ⚠️
16
+ #
17
+ # The password to log into the Puppet Enterprise console.
18
+ #
19
+ # After installation, you may set the console_admin_password to an empty
20
+ # string to avoid storing a password in plain text.
21
+ #--------------------------------------------------------------------------
22
+ "console_admin_password": "#{ENV['PT_console_password']}"
23
+
24
+
25
+ #--------------------------------------------------------------------------
26
+ # PE Component assignments.
27
+ #
28
+ # If you're performing a monolithic install (recommended), there is no need
29
+ # to change the default settings, and you do not need to set the
30
+ # puppetdb_host and console_host parameters.
31
+ #
32
+ # When performing a split install, do not use the %{::trusted.certname} fact.
33
+ # Instead set the FQDN for all three PE component nodes.
34
+ # For more information, refer to:
35
+ # https://docs.puppet.com/pe/latest/install_text_mode_split.html
36
+ #
37
+ # Overview of PE Components:
38
+ # https://docs.puppet.com/pe/latest/pe_architecture_overview.html
39
+ #-------------------------------------------------------------------------
40
+
41
+ # Puppet Enterprise Master
42
+ "puppet_enterprise::puppet_master_host": "%{::trusted.certname}"
43
+
44
+ # Puppet Enterprise Console
45
+ #"puppet_enterprise::console_host": ""
46
+
47
+ # PuppetDB
48
+ #"puppet_enterprise::puppetdb_host": ""
49
+
50
+ # Hostname of database node if pe-postgres is being run on its own node
51
+ #"puppet_enterprise::database_host": ""
52
+
53
+ #--------------------------------------------------------------------------
54
+ # DATABASE CONFIGURATION
55
+ #
56
+ # Puppet Enterprise uses PostgreSQL as a database backend.
57
+ # PE can install and manage a new one (recommended), or you can use an
58
+ # existing instance.
59
+ #
60
+ # For details on using an existing PostgreSQL database, visit:
61
+ # https://docs.puppet.com/pe/latest/install_system_requirements.html
62
+ #
63
+ # UPGRADE NOTE:
64
+ # If you’re upgrading and have previously used non-default database names and
65
+ # users, you must uncomment and change these parameters to match what you
66
+ # have used.
67
+ #--------------------------------------------------------------------------
68
+
69
+ #"puppet_enterprise::activity_database_name": "pe-activity"
70
+ #"puppet_enterprise::activity_service_migration_db_user": "pe-activity"
71
+ #"puppet_enterprise::activity_service_regular_db_user": "pe-activity"
72
+ #"puppet_enterprise::classifier_database_name": "pe-classifier"
73
+ #"puppet_enterprise::classifier_service_migration_db_user": "pe-classifier"
74
+ #"puppet_enterprise::classifier_service_regular_db_user": "pe-classifier"
75
+ #"puppet_enterprise::orchestrator_database_name": "pe-orchestrator"
76
+ #"puppet_enterprise::orchestrator_service_migration_db_user": "pe-orchestrator"
77
+ #"puppet_enterprise::orchestrator_service_regular_db_user": "pe-orchestrator"
78
+ #"puppet_enterprise::rbac_database_name": "pe-rbac"
79
+ #"puppet_enterprise::rbac_service_migration_db_user": "pe-rbac"
80
+ #"puppet_enterprise::rbac_service_regular_db_user": "pe-rbac"
81
+ #"puppet_enterprise::puppetdb_database_name": "pe-puppetdb"
82
+ #"puppet_enterprise::puppetdb_database_user": "pe-puppetdb"
83
+
84
+
85
+ # EXTERNAL POSTGRES OPTIONS ONLY
86
+ # If you're using an existing PostgreSQL instance that was not set up by
87
+ # Puppet Enterprise, set the following parameters:
88
+
89
+ #"puppet_enterprise::database_ssl": false
90
+ #"puppet_enterprise::database_cert_auth": false
91
+ #"puppet_enterprise::activity_database_password": "PASSWORD"
92
+ #"puppet_enterprise::classifier_database_password": "PASSWORD"
93
+ #"puppet_enterprise::orchestrator_database_password": "PASSWORD"
94
+ #"puppet_enterprise::rbac_database_password": "PASSWORD"
95
+ #"puppet_enterprise::puppetdb_database_password": "PASSWORD"
96
+
97
+
98
+ #--------------------------------------------------------------------------
99
+ # ADVANCED AND CUSTOM PARAMETERS
100
+ #
101
+ # You can use the following parameters as needed, or add your own parameters
102
+ # to this section.
103
+ #
104
+ # For a complete list of parameters and what they do, visit:
105
+ # https://docs.puppet.com/pe/latest/install_pe_conf_param.html
106
+ #--------------------------------------------------------------------------
107
+
108
+ # DNS altnames to be added to the SSL certificate generated for the Puppet
109
+ # master node. Only used at install time.
110
+ #"pe_install::puppet_master_dnsaltnames": ["puppet"]
111
+
112
+ #Enabling this configures code manager, all three below values should be enabled and populated at the same time.
113
+ #"puppet_enterprise::profile::master::code_manager_auto_configure": true
114
+
115
+ #The ssh url to your existing control repo.
116
+ #"puppet_enterprise::profile::master::r10k_remote": "git@your.git.server.com:puppet/control.git"
117
+
118
+ #The private key to your puppetmaster for establishing key-based ssh authentication to your vcs.
119
+ #"puppet_enterprise::profile::master::r10k_private_key": "/etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa"
120
+
121
+ #test key that does nothing
122
+ "ref_arch::name": "basic"
123
+ }
124
+ PE_CONF
125
+ # rubocop:enable Style/FormatStringToken
126
+
127
+ FileUtils.mkdir_p "/tmp/ref_arch_setup" unless Dir.exist? "/tmp/ref_arch_setup"
128
+ File.open("/tmp/ref_arch_setup/pe.conf", "w") { |f| f.write(pe_conf) }
@@ -0,0 +1,14 @@
1
+ {
2
+ "description": "Installs PE master on a node",
3
+
4
+ "parameters": {
5
+ "pe_tarball_path": {
6
+ "description": "The file path to the PE tarball that was downloaded and copied to the master",
7
+ "type": "String[1]"
8
+ },
9
+ "pe_conf_path": {
10
+ "description": "The file path to the pe.conf file that was copied to the master",
11
+ "type": "String[1]"
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Install PE:
4
+ # First, copy the PE installer tarball and pe_conf file to the node
5
+ # Then, execute the task as per the following example:
6
+ # bolt task --modulepath modules run 'ref_arch_setup::install_pe pe_tarball_path=puppet-enterprise-2018.1.1-el-7-x86_64.tar.gz pe_conf_path=pe.conf' --nodes bdjshmr8bx75q2a.delivery.puppetlabs.net
7
+
8
+ execute_command() {
9
+ cmd=$1
10
+ echo "Executing: $cmd"
11
+ eval $cmd
12
+ cmd_exit_code=$?
13
+
14
+ # if number of args is 1, check for exit code = 0, otherwise check for exit code = value of second arg
15
+ if [ $# -eq 1 ]
16
+ then
17
+ expected_exit_code=0
18
+ else
19
+ expected_exit_code=$2
20
+ fi
21
+ if [ $cmd_exit_code -ne $expected_exit_code ]
22
+ then
23
+ echo "Command '$1' failed - expected_exit_code: $expected_exit_code, actual_exit_code: $cmd_exit_code"
24
+ exit 1
25
+ fi
26
+ }
27
+
28
+ # Sometimes it takes more than one run ...
29
+
30
+ execute_puppet_until_idempotent() {
31
+ puppet_command="puppet agent -t"
32
+
33
+ # The following could be converted into parameters with defaults ...
34
+
35
+ maximum_number_of_puppet_runs=8
36
+ sleep_seconds_when_puppet_run_in_progress=16
37
+ retry_when_success_with_failures=false
38
+
39
+ for run in $(seq 1 $maximum_number_of_puppet_runs); do
40
+ echo "Executing: '$puppet_command'"
41
+
42
+ # To both capture and output command output ...
43
+ exec 5>&1
44
+ puppet_command_output=$($puppet_command | tee /dev/fd/5; exit "${PIPESTATUS[0]}")
45
+ puppet_exit_code=$?
46
+
47
+ if echo "$puppet_command_output" | grep -q "Run of Puppet configuration client already in progress"; then
48
+ puppet_run_in_progress=true
49
+ else
50
+ puppet_run_in_progress=false
51
+ fi
52
+
53
+ # 0: The run succeeded with no changes or failures; the system was already in the desired state
54
+ if [ $puppet_exit_code -eq 0 ]; then
55
+ break
56
+ fi
57
+
58
+ # 1: The run failed, or wasn't attempted due to another run already in progress.
59
+ if [ $puppet_exit_code -eq 1 ]; then
60
+ if [ "$puppet_run_in_progress" = true ]; then
61
+ echo "Sleeping $sleep_seconds_when_puppet_run_in_progress seconds while waiting for another run already in progress"
62
+ sleep $sleep_seconds_when_puppet_run_in_progress
63
+ continue
64
+ else
65
+ echo "ERROR: '$puppet_command' failed with exit code: $puppet_exit_code"
66
+ exit 1
67
+ fi
68
+ fi
69
+
70
+ # 2: The run succeeded, and some resources were changed.
71
+ if [ $puppet_exit_code -eq 2 ]; then
72
+ continue
73
+ fi
74
+
75
+ # 4: The run succeeded, and some resources failed.
76
+ if [ $puppet_exit_code -eq 4 ]; then
77
+ if [ "$retry_when_success_with_failures" = true ]; then
78
+ continue
79
+ else
80
+ echo "ERROR: '$puppet_command' failed with exit code: $puppet_exit_code"
81
+ exit 1
82
+ fi
83
+ fi
84
+
85
+ # 6: The run succeeded, and included both changes and failures.
86
+ if [ $puppet_exit_code -eq 6 ]; then
87
+ if [ "$retry_when_success_with_failures" = true ] ; then
88
+ continue
89
+ else
90
+ echo "ERROR: '$puppet_command' failed with exit code: $puppet_exit_code"
91
+ exit 1
92
+ fi
93
+ fi
94
+ done
95
+ }
96
+
97
+ #check that pe.conf is present
98
+ if [ ! -f $PT_pe_conf_path ]; then
99
+ echo "ERROR: Specified pe.conf file not found: $PT_pe_conf_path"
100
+ exit 1
101
+ fi
102
+
103
+ #check that pe tarball is present
104
+ if [ ! -f $PT_pe_tarball_path ]; then
105
+ echo "ERROR: Specified pe tarball not found: $PT_pe_tarball_path"
106
+ exit 1
107
+ fi
108
+
109
+ # Install tar using existing package manager if it is not already installed
110
+ if [ "" == "`which tar`" ]
111
+ then
112
+ echo "Tar Not Found"
113
+ if [ -n "`which apt-get`" ]
114
+ then
115
+ execute_command "apt-get -y install tar"
116
+ elif [ -n "`which yum`" ]
117
+ then
118
+ execute_command "yum -y install tar"
119
+ else
120
+ echo "OS does not have apt-get or yum package manager"
121
+ exit 1
122
+ fi
123
+ fi
124
+
125
+ execute_command "tar -xvf $PT_pe_tarball_path -C /tmp/ref_arch_setup"
126
+
127
+ # Using -* so we don't have to know the specific version, or parse it from the install path
128
+ execute_command "sh /tmp/ref_arch_setup/puppet-enterprise-*/puppet-enterprise-installer -c $PT_pe_conf_path"
129
+
130
+ # Must run puppet agent twice, see https://puppet.com/docs/pe/2017.3/installing/installing_pe.html#text-mode-installation-options-for-monolithic-installations
131
+ execute_puppet_until_idempotent
132
+ exit 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ref_arch_setup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-13 00:00:00.000000000 Z
11
+ date: 2018-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bolt
@@ -16,14 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.17'
19
+ version: 0.22.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.17'
26
+ version: 0.22.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: oga
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.15'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: beaker
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: beaker-vmpooler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
27
69
  description: |-
28
70
  This gem provides methods for for setting up /
29
71
  Puppet Enterprise reference architectures
@@ -34,14 +76,25 @@ executables:
34
76
  extensions: []
35
77
  extra_rdoc_files: []
36
78
  files:
79
+ - Boltdir/Puppetfile
37
80
  - CONTRIBUTING.md
38
81
  - MAINTAINERS
39
82
  - README.md
40
83
  - bin/ref_arch_setup
84
+ - fixtures/pe.conf
85
+ - fixtures/puppet-enterprise-2019.0-rc1-7-gd82666f-el-7-x86_64.tar
41
86
  - lib/ref_arch_setup.rb
87
+ - lib/ref_arch_setup/bolt_helper.rb
42
88
  - lib/ref_arch_setup/cli.rb
89
+ - lib/ref_arch_setup/download_helper.rb
43
90
  - lib/ref_arch_setup/install.rb
44
91
  - lib/ref_arch_setup/version.rb
92
+ - modules/ref_arch_setup/tasks/download_pe_tarball.json
93
+ - modules/ref_arch_setup/tasks/download_pe_tarball.sh
94
+ - modules/ref_arch_setup/tasks/generate_pe_conf.json
95
+ - modules/ref_arch_setup/tasks/generate_pe_conf.rb
96
+ - modules/ref_arch_setup/tasks/install_pe.json
97
+ - modules/ref_arch_setup/tasks/install_pe.sh
45
98
  homepage: https://github.com/puppetlabs/ref_arch_setup
46
99
  licenses:
47
100
  - Apache2
@@ -54,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
107
  requirements:
55
108
  - - ">="
56
109
  - !ruby/object:Gem::Version
57
- version: '0'
110
+ version: 2.3.0
58
111
  required_rubygems_version: !ruby/object:Gem::Requirement
59
112
  requirements:
60
113
  - - ">="
@@ -62,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
115
  version: '0'
63
116
  requirements: []
64
117
  rubyforge_project:
65
- rubygems_version: 2.5.2
118
+ rubygems_version: 2.6.13
66
119
  signing_key:
67
120
  specification_version: 4
68
121
  summary: Tool for setting up reference architectures