From ef535294ecd79a47b74f1da980cc79492af1b158 Mon Sep 17 00:00:00 2001 From: Vlad Ghinea Date: Sun, 25 Oct 2015 08:44:35 -0500 Subject: [PATCH 1/5] Test ssh keys --- dist/profile/manifests/base.pp | 6 +++--- dist/profile/spec/classes/base_spec.rb | 2 ++ dist/profile/spec/fixtures/hiera/test.yaml | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/profile/manifests/base.pp b/dist/profile/manifests/base.pp index 6b54954..1ad06b1 100644 --- a/dist/profile/manifests/base.pp +++ b/dist/profile/manifests/base.pp @@ -19,11 +19,11 @@ } else { $user = 'root' } - $authorized_keys = hiera_hash('authorized_keys', undef) - if ($authorized_keys) { + $ssh_authorized_keys = hiera_hash('ssh_authorized_keys', undef) + if ($ssh_authorized_keys) { create_resources( 'ssh_authorized_key', - $authorized_keys, + $ssh_authorized_keys, { user => $user } ) } diff --git a/dist/profile/spec/classes/base_spec.rb b/dist/profile/spec/classes/base_spec.rb index 9fcb067..8627639 100644 --- a/dist/profile/spec/classes/base_spec.rb +++ b/dist/profile/spec/classes/base_spec.rb @@ -13,6 +13,8 @@ it { should contain_service('puppet').with_ensure('stopped').with_enable('false') } it { should contain_service('mcollective').with_ensure('stopped').with_enable('false') } + + it { is_expected.to contain_ssh_authorized_key('testkey') } end end end diff --git a/dist/profile/spec/fixtures/hiera/test.yaml b/dist/profile/spec/fixtures/hiera/test.yaml index 1fbe0fc..35950b8 100644 --- a/dist/profile/spec/fixtures/hiera/test.yaml +++ b/dist/profile/spec/fixtures/hiera/test.yaml @@ -6,3 +6,5 @@ classes: - stdlib - apt +ssh_authorized_keys: + testkey: {} From cd08350487ad9d0a55c08cae83c355697864ecd9 Mon Sep 17 00:00:00 2001 From: Vlad Ghinea Date: Sun, 25 Oct 2015 08:59:32 -0500 Subject: [PATCH 2/5] Test CodeDeploy --- dist/profile/manifests/ec2.pp | 42 +++++++++++++-------------- dist/profile/spec/classes/ec2_spec.rb | 5 ++++ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/dist/profile/manifests/ec2.pp b/dist/profile/manifests/ec2.pp index e20f870..4983e9f 100644 --- a/dist/profile/manifests/ec2.pp +++ b/dist/profile/manifests/ec2.pp @@ -24,27 +24,27 @@ provider => 'pip', } - # AWS CodeDeploy - # wget::fetch {'CodeDeploy Deb': - # source => 'https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/codedeploy-agent_all.deb', - # destination => '/tmp/codedeploy-agent_all.deb', - # } - # package {'CodeDeploy Agent': - # ensure => latest, - # name => 'codedeploy-agent', - # source => '/tmp/codedeploy-agent_all.deb', - # provider => dpkg, - # require => [ - # Wget::Fetch['CodeDeploy Deb'], - # Package['ruby2.0', 'gdebi-core'] - # ], - # } - # service {'CodeDeploy Service': - # ensure => running, - # enable => true, - # name => 'codedeploy-agent', - # require => Package['CodeDeploy Agent'], - # } + #AWS CodeDeploy + wget::fetch {'CodeDeploy Deb': + source => 'https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/codedeploy-agent_all.deb', + destination => '/tmp/codedeploy-agent_all.deb', + } + package {'CodeDeploy Agent': + ensure => latest, + name => 'codedeploy-agent', + source => '/tmp/codedeploy-agent_all.deb', + provider => dpkg, + require => [ + Wget::Fetch['CodeDeploy Deb'], + Package['ruby2.0', 'gdebi-core'] + ], + } + service {'CodeDeploy Service': + ensure => running, + enable => true, + name => 'codedeploy-agent', + require => Package['CodeDeploy Agent'], + } # Docker-Compose # wget::fetch {'Docker-Compose': diff --git a/dist/profile/spec/classes/ec2_spec.rb b/dist/profile/spec/classes/ec2_spec.rb index 8bf1095..ca287a2 100644 --- a/dist/profile/spec/classes/ec2_spec.rb +++ b/dist/profile/spec/classes/ec2_spec.rb @@ -18,7 +18,12 @@ it { should contain_package('gdebi-core') } it { should contain_package('aws-sdk').with_provider('puppet_gem') } + it { should contain_package('AWS CloudFormation').with_name('aws-cfn-bootstrap').with_provider('pip') } + + it { should have_wget__fetch_resource_count(1) } + it { should contain_package('CodeDeploy Agent').with_name('codedeploy-agent').with_provider('dpkg') } + it { should contain_service('CodeDeploy Service').with_name('codedeploy-agent') } end end end From ea0b252c233d959682b550105b128d1712f8f5f3 Mon Sep 17 00:00:00 2001 From: Vlad Ghinea Date: Sun, 25 Oct 2015 09:19:01 -0500 Subject: [PATCH 3/5] Test wget define --- dist/profile/spec/classes/ec2_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/profile/spec/classes/ec2_spec.rb b/dist/profile/spec/classes/ec2_spec.rb index ca287a2..2206b61 100644 --- a/dist/profile/spec/classes/ec2_spec.rb +++ b/dist/profile/spec/classes/ec2_spec.rb @@ -21,7 +21,8 @@ it { should contain_package('AWS CloudFormation').with_name('aws-cfn-bootstrap').with_provider('pip') } - it { should have_wget__fetch_resource_count(1) } + it { should contain_package('wget') } + it { should contain_wget__fetch('CodeDeploy Deb') } it { should contain_package('CodeDeploy Agent').with_name('codedeploy-agent').with_provider('dpkg') } it { should contain_service('CodeDeploy Service').with_name('codedeploy-agent') } end From dc18e30760ab742ea8c7f3b558cc7a74054c48c4 Mon Sep 17 00:00:00 2001 From: Vlad Ghinea Date: Sun, 25 Oct 2015 09:31:54 -0500 Subject: [PATCH 4/5] Improve manifests --- dist/profile/manifests/base.pp | 2 +- dist/profile/manifests/ec2.pp | 21 +++++---------------- dist/profile/spec/classes/ec2_spec.rb | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/dist/profile/manifests/base.pp b/dist/profile/manifests/base.pp index 1ad06b1..3954573 100644 --- a/dist/profile/manifests/base.pp +++ b/dist/profile/manifests/base.pp @@ -20,7 +20,7 @@ $user = 'root' } $ssh_authorized_keys = hiera_hash('ssh_authorized_keys', undef) - if ($ssh_authorized_keys) { + if ($ssh_authorized_keys != undef) { create_resources( 'ssh_authorized_key', $ssh_authorized_keys, diff --git a/dist/profile/manifests/ec2.pp b/dist/profile/manifests/ec2.pp index 4983e9f..3842242 100644 --- a/dist/profile/manifests/ec2.pp +++ b/dist/profile/manifests/ec2.pp @@ -11,14 +11,15 @@ ]) # AWS SDK for Ruby - package {'aws-sdk': - ensure => installed, + package {'AWS SDK CLI': + ensure => present, + name => 'aws-sdk', provider => 'puppet_gem', } # AWS CloudFormation scripts package {'AWS CloudFormation': - ensure => installed, + ensure => present, name => 'aws-cfn-bootstrap', source => 'https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz', provider => 'pip', @@ -30,7 +31,7 @@ destination => '/tmp/codedeploy-agent_all.deb', } package {'CodeDeploy Agent': - ensure => latest, + ensure => present, name => 'codedeploy-agent', source => '/tmp/codedeploy-agent_all.deb', provider => dpkg, @@ -45,16 +46,4 @@ name => 'codedeploy-agent', require => Package['CodeDeploy Agent'], } - - # Docker-Compose - # wget::fetch {'Docker-Compose': - # source => "https://github.com/docker/compose/releases/download/1.4.0/docker-compose-${::kernel}-${::os['hardware']}", - # destination => '/usr/local/bin/docker-compose', - # require => Class['Docker'], - # } - # file {'/usr/local/bin/docker-compose': - # mode => '0755', - # require => Wget::Fetch['Docker-Compose'], - # } } - diff --git a/dist/profile/spec/classes/ec2_spec.rb b/dist/profile/spec/classes/ec2_spec.rb index 2206b61..1f4cbc0 100644 --- a/dist/profile/spec/classes/ec2_spec.rb +++ b/dist/profile/spec/classes/ec2_spec.rb @@ -17,7 +17,7 @@ it { should contain_package('ruby2.0') } it { should contain_package('gdebi-core') } - it { should contain_package('aws-sdk').with_provider('puppet_gem') } + it { should contain_package('AWS SDK CLI').with_name('aws-sdk').with_provider('puppet_gem') } it { should contain_package('AWS CloudFormation').with_name('aws-cfn-bootstrap').with_provider('pip') } From be0ab022b75fd0f93c42d5c38c0419c0455f142a Mon Sep 17 00:00:00 2001 From: Vlad Ghinea Date: Sun, 25 Oct 2015 14:03:18 -0500 Subject: [PATCH 5/5] Update README --- README.md | 20 +++++++++----------- manifests/bootstrap.pp | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 97372b1..4ea9ab8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This project is still in a prototype development stage. ## Overview -Controls Vlad's environments. +Vlad's Puppet Control Repo. ## Description ### Puppetfile @@ -19,9 +19,12 @@ This file can override several settings whenever the Puppet master is serving nodes assigned to that environment. [Config Files: environment.conf](https://docs.puppetlabs.com/puppet/latest/reference/config_file_environment.html) -### data +### bin/ +Contains various executable scripts. + +### data/ Contains the hiera data files. It's intended to serve as a base only, for -public data, and it should be overwritten or ammended with data from private +public data, and it should be overwritten or amended with data from private sources. ### dist/ @@ -29,15 +32,10 @@ Contains organization-specific roles and profiles. This directory is specified as a modulepath in environment.conf [Designing Puppet – Roles and Profiles.](http://www.craigdunn.org/2012/05/239/) -### hooks/ -Contains GIT hooks. - ### manifests/ -Contains Puppet's main manifests: - - `site.pp` - -### provision/ -Contains the scripts and files that are used to spin up the nodes. +Contains Puppet's manifests: + - `bootstrap.pp`: the bootstrapping manifest + - `site.pp`: the main manifest ## License ## Licensed under the Apache License, Version 2.0. diff --git a/manifests/bootstrap.pp b/manifests/bootstrap.pp index 1129848..2e5d1d7 100644 --- a/manifests/bootstrap.pp +++ b/manifests/bootstrap.pp @@ -40,7 +40,7 @@ } # Install and configure R10K -# FIXME: Temporary fix until a new version of r10k (this is already in master) +# FIXME: Temporary fix until R10K > 2.0.3 (this is already in master) file {'/etc/puppetlabs/r10k': ensure => 'directory', owner => 'root',