Skip to content

Commit 765e572

Browse files
authored
Merge pull request #5 from jantman/newnew
Major layout change
2 parents 6a671bf + 620a956 commit 765e572

26 files changed

+65
-105
lines changed

.fixtures.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ fixtures:
4141
repo: "https://github.com/puppetlabs/puppetlabs-apt.git"
4242
ref: "2.3.0"
4343
symlinks:
44-
workstation_bootstrap: "#{source_dir}/puppet/modules/workstation_bootstrap"
44+
workstation_bootstrap: "#{source_dir}/modules/local/workstation_bootstrap"
4545
privatepuppet: "#{source_dir}/spec/fixtures/privatepuppet"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ spec/fixtures/modules/
2020
spec/fixtures/hiera.yaml
2121
tmp/
2222
vendor/
23+
/hiera.yaml
24+
modules/r10k

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [3.0.0] Released 2018-05-21
2+
3+
- Completely rework from previous system-wide installation to be run directly from git clone
4+
15
## [2.0.0] Released 2018-02-04
26

37
- Update all dependencies and layout via modulesync, to modern Puppet5 version.

Gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ group :system_tests do
5656
gem "beaker-docker", '>= 0.3.0', :require => false
5757
gem "puppet-module-posix-system-r#{minor_version}", :require => false, :platforms => "ruby"
5858
gem "puppet-module-win-system-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
59-
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3')
59+
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3')
6060
gem "beaker-pe", :require => false
61-
gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION'])
61+
gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION'])
6262
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
63-
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
63+
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
6464
gem "puppet-blacksmith", '>= 4.1.1', :require => false
6565
gem "vandamme", :require => false
6666
gem "octokit", '~> 4.0', :require => false
@@ -75,6 +75,8 @@ gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])
7575
gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION']
7676
gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION']
7777

78+
gem 'r10k'
79+
7880
# Evaluate Gemfile.local if it exists
7981
if File.exists? "#{__FILE__}.local"
8082
eval(File.read("#{__FILE__}.local"), binding)
File renamed without changes.

README.md

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,38 @@
44

55
#### Table of Contents
66

7-
1. [Overview](#overview)
7+
1. [Important Notice About Version 3.0.0](#important-notice-about-version-300)
8+
2. [Overview](#overview)
89
* [Warning](#warning)
9-
2. [Prerequisites](#prerequisites)
10+
3. [Prerequisites](#prerequisites)
1011
* [General](#general)
1112
* [Arch Linux](#arch-linux)
12-
3. [Customization](#customization)
13+
4. [Customization](#customization)
1314
* [Hiera Data](#hiera-data)
1415
* [Sensitive Information](#sensitive-information)
15-
4. [Setup](#setup)
16-
5. [Usage](#usage)
17-
6. [Reference](#reference)
16+
5. [Setup](#setup)
17+
6. [Usage](#usage)
18+
7. [Reference](#reference)
1819
* [site.pp manifests](#site.pp-manifest)
1920
* [Puppetfile](#puppetfile)
2021
* [workstation_bootstrap module](#workstation_bootstrap-module)
2122
* [Hiera](#hiera)
2223
* [Hiera Ordering](#hiera-ordering)
23-
7. [Testing](#testing)
24+
8. [Testing](#testing)
25+
26+
## Important Notice About Version 3.0.0
27+
28+
Versions 2.0.0 and earlier of this repository were a full [control repository](https://puppet.com/docs/pe/latest/code_management/control_repo.html) setup for environments and intended to be checked out into the distribution default Puppet config directories (i.e. ``/etc/puppet/code``). I've found this to be cumbersome, unusual, and difficult to maintain. As a result, Version 3.0.0 changes this repository to run directly from the git clone in the way that masterless Puppet provisioners are typically used. Hopefully this will make it easier for others to use as an example.
2429

2530
## Overview
2631

27-
This is an example of a puppet/[r10k](https://github.com/puppetlabs/r10k) [control repository](https://puppet.com/docs/pe/latest/code_management/control_repo.html) for use with my [archlinux_workstation](https://forge.puppet.com/jantman/archlinux_workstation) and optionally [archlinux_macbookretina](https://forge.puppet.com/jantman/archlinux_macbookretina) Puppet modules. This specific repository includes some personal configuration of mine, and is intended to be forked and modified as described below. This is intended to be a generic framework for anyone who wants to use Puppet to manage their workstation's configuration. The project provides some sane (though opinionated) defaults, and instructions for how to change them. The defaults are geared towards Arch Linux, but the core in this repository can be used for any distribution, or just as an example/starting point.
32+
This is an example of a puppet / [r10k](https://github.com/puppetlabs/r10k) masterless repository for use with my [archlinux_workstation](https://forge.puppet.com/jantman/archlinux_workstation) and optionally [archlinux_macbookretina](https://forge.puppet.com/jantman/archlinux_macbookretina) Puppet modules. This specific repository includes some personal configuration of mine, and is intended to be forked and modified as described below. This is intended to be a generic framework for anyone who wants to use Puppet to manage their workstation's configuration. The project provides some sane (though opinionated) defaults, and instructions for how to change them. The defaults are geared towards Arch Linux, but the core in this repository can be used for any distribution, or just as an example/starting point.
2833

2934
In general, what this repository has is:
3035

3136
* a [Puppetfile](#puppetfile) for use with r10k, to install all dependencies.
3237
* a [site.pp main manifest](#site.pp-manifest), which sets up the top-scope things needed for [puppetlabs-firewall](https://forge.puppetlabs.com/puppetlabs/firewall)) and uses your [hiera data](#hiera) to include the classes you want to use.
33-
* Some helper scripts under ``bin/`` to aid in installation and use. See [Setup](#setup) and [Usage](#usage).
38+
* Some helper scripts under ``bin/`` to aid in use. See [Setup](#setup) and [Usage](#usage).
3439
* Documentation on initial setup of an Arch computer to use with this repo.
3540

3641
### Warning
@@ -68,9 +73,9 @@ Distro-specific instructions follow.
6873
Here's how to make this project do what you want:
6974

7075
1. Fork this repository.
71-
2. Edit ``puppet/Puppetfile`` to contain all of the modules that you need as well as their dependencies. Unlike ``puppet module install``, r10k does not have dependency resolution.
72-
3. Edit the files under ``puppet/hiera/`` to do what you need. See below for more information.
73-
4. Edit ``puppet/manifests/site.pp`` as needed, though the default should be acceptable for most people.
76+
2. Edit ``Puppetfile`` to contain all of the modules that you need as well as their dependencies. Unlike ``puppet module install``, r10k does not have dependency resolution.
77+
3. Edit the files under ``hiera/`` to do what you need. See below for more information.
78+
4. Edit ``manifests/site.pp`` as needed, though the default should be acceptable for most people.
7479
5. Edit the spec tests under ``spec/hosts`` to match your changes in the previous steps.
7580
6. Commit and push your changes.
7681

@@ -104,23 +109,22 @@ Most users will have some sensitive information that they want on their machine
104109

105110
To set up the project on one of your own machines:
106111

107-
1. ``cd /etc/puppetlabs/code``
108-
2. ``git clone https://github.com/jantman/workstation-bootstrap.git workstation-bootstrap`` (or your fork, if you made one)
109-
3. ``cd workstation-bootstrap``
110-
4. ``./bin/setup.sh``
111-
5. Deploy the modules with r10k and then run Puppet: ``./bin/run_r10k_puppet.sh``. Assuming you're running under Arch Linux and using my [archlinux_workstation](https://github.com/jantman/puppet-archlinux-workstation) module, you'll want to do this either in a screen session or redirect the output to a file; at some point in the run, Xorg and SDDM will start up and your display will turn graphical. You can either login or use ``Ctrl + Alt + F2`` to get to a text console. If puppet dies when the ``sddm`` service starts, just re-run it.
112-
6. After the initial run, set the password for your newly-created user and then reboot.
113-
7. Log in as your user.
112+
1. ``git clone https://github.com/jantman/workstation-bootstrap.git`` (or your fork, if you made one) somewhere convenient; I use ``/root`` for ease.
113+
2. ``cd workstation-bootstrap``
114+
3. To deploy the dependencies with r10k and then run Puppet: ``./bin/run_r10k_puppet.sh``. Assuming you're running under Arch Linux and using my [archlinux_workstation](https://github.com/jantman/puppet-archlinux-workstation) module, you'll want to do this either in a screen session or redirect the output to a file; at some point in the run, Xorg and SDDM will start up and your display will turn graphical. You can either login or use ``Ctrl + Alt + F2`` to get to a text console. If puppet dies when the ``sddm`` service starts, just re-run it.
115+
4. After the initial run, set the password for your newly-created user and then reboot.
116+
5. Log in as your user.
114117

115118
## Usage
116119

117120
* To run the r10k deploy, ``./bin/run_r10k.sh``
118121
* To run puppet on ``site.pp``, ``./bin/run_puppet.sh``
119122
* To run r10k and then puppet, ``./bin/run_r10k_puppet.sh``
120-
* To find the value of a given key in the current Hiera data, ``./bin/hiera_show_value.sh KEY_NAME``
121123

122124
``./bin/run_puppet.sh`` and ``./bin/run_r10k_puppet.sh`` will add any command-line arguments that you specify to the ``puppet`` command before the path to ``site.pp`` (i.e. ``./bin/run_r10k_puppet.sh --noop`` will end run ``puppet`` with ``--noop``).
123125

126+
I generally create symlinks in ``~/bin`` to these scripts for ease.
127+
124128
## Firewall Rules and Docker
125129

126130
The pre-1.0.0 behavior of this module was to include a global firewall resource purge, to remove all unmanaged iptables rules:
@@ -160,27 +164,18 @@ At this moment, what this code does is:
160164

161165
### workstation_bootstrap module
162166

163-
This module has two classes, ``workstation_bootstrap::firewall_pre`` and ``workstation_bootstrap::firewall_post``, which
167+
The base ``workstation_bootstrap`` module can be found in ``modules/local/workstation_bootstrap``. It has two classes, ``workstation_bootstrap::firewall_pre`` and ``workstation_bootstrap::firewall_post``, which
164168
do setup of default Firewall module rules, including accepting SSH on port 22.
165169

166170
### Puppetfile
167171

168-
* [archlinux_workstation](https://forge.puppet.com/jantman/archlinux_workstation)
169-
* [archlinux_macbookretina](https://forge.puppet.com/jantman/archlinux_macbookretina)
170-
* [puppetlabs/stdlib](https://forge.puppetlabs.com/puppetlabs/stdlib)
171-
* [saz/sudo](https://forge.puppetlabs.com/saz/sudo) (dependency of archlinux_workstation)
172-
* [saz/ssh](https://forge.puppetlabs.com/saz/ssh) (dependency of archlinux_workstation)
173-
* [puppetlabs/firewall](https://forge.puppetlabs.com/puppetlabs/firewall)
174-
* [puppetlabs/inifile](https://forge.puppetlabs.com/puppetlabs/inifile)
175-
* [puppetlabs/vcsrepo](https://forge.puppetlabs.com/puppetlabs/vcsrepo)
176-
* [eirc/single_user_rvm](https://forge.puppetlabs.com/eirc/single_user_rvm)
177-
* [nanliu/staging](https://forge.puppetlabs.com/nanliu/staging)
172+
See [Puppetfile](Puppetfile) itself for the current list of included dependencies.
178173

179174
By default, the Puppetfile also includes my personal "privatepuppet" module. You should comment this out or replace it with your own personal module(s).
180175

181176
### Hiera
182177

183-
The Hiera hierarchy used is as follows:
178+
The Hiera hierarchy used is rooted at ``hiera/`` and has configurations as follows:
184179

185180
* ``defaults.yaml`` - default configuration and classes
186181
* ``osfamily/Archlinux.yaml`` - include ``archlinux-workstation`` class on Arch Linux

Rakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ require 'puppet-strings' if Bundler.rubygems.find_name('puppet-strings').any?
55
require 'vandamme' if Bundler.rubygems.find_name('vandamme').any?
66
require 'octokit' if Bundler.rubygems.find_name('octokit').any?
77
require 'json'
8+
require 'fileutils'
89

910
PuppetLint.configuration.fail_on_warnings = true
1011
PuppetLint.configuration.send('relative')
12+
PuppetLint.configuration.pattern = 'modules/local/**/*.pp'
1113

1214
desc "NON-PARALLEL version of release_checks"
1315
task :release_checks_nonparallel do
16+
FileUtils.rm_rf('modules/r10k') if Dir.exist?('modules/r10k')
1417
Rake::Task[:lint].invoke
1518
Rake::Task[:validate].invoke
1619
Rake::Task[:spec].invoke

bin/hiera_show_value.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

bin/run_puppet.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#!/bin/bash
22

3+
CLONEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
34
set -x
5+
cd $CLONEDIR
46

5-
puppet apply --verbose $@ /etc/puppetlabs/code/environments/production/manifests/site.pp
7+
sed "s|%%CLONEDIR%%|${CLONEDIR}|g" hiera.yaml.template > hiera.yaml
8+
9+
puppet apply --verbose $@ \
10+
--hiera_config=${CLONEDIR}/hiera.yaml \
11+
--modulepath="${CLONEDIR}/modules/local:${CLONEDIR}/modules/r10k" \
12+
${CLONEDIR}/manifests/site.pp

bin/run_r10k.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22

3+
CLONEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
34
set -x
4-
pushd /etc/puppetlabs/code/workstation-bootstrap/puppet/
5+
cd $CLONEDIR
56
git fetch && git pull
6-
popd
7-
PUPPETFILE=/etc/puppetlabs/code/workstation-bootstrap/puppet/Puppetfile PUPPETFILE_DIR=/etc/puppetlabs/code/workstation-bootstrap/puppet/modules /usr/bin/r10k puppetfile install $@
7+
PUPPETFILE=${CLONEDIR}/Puppetfile \
8+
PUPPETFILE_DIR=${CLONEDIR}/modules/r10k \
9+
/usr/bin/r10k puppetfile install -v $@

bin/run_r10k_puppet.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
22

3+
CLONEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
34
set -x
4-
/etc/puppetlabs/code/workstation-bootstrap/bin/run_r10k.sh && /etc/puppetlabs/code/workstation-bootstrap/bin/run_puppet.sh $@
5+
cd $CLONEDIR
6+
./bin/run_r10k.sh && ./bin/run_puppet.sh $@

bin/setup.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

puppet/config/hiera.yaml renamed to hiera.yaml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ hierarchy:
1111
path: "user_config.yaml"
1212
defaults:
1313
data_hash: yaml_data
14-
datadir: /etc/puppetlabs/code/workstation-bootstrap/puppet/hiera
14+
datadir: %%CLONEDIR%%/hiera
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

metadata.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "jantman-workstation_bootstrap",
3-
"version": "2.0.0",
4-
"summary": "sample control repository and main module, geared towards Arch Linux",
3+
"version": "3.0.0",
4+
"summary": "sample main repository and module, geared towards Arch Linux",
55
"author": "jantman",
6-
"description": "This is an example of a puppet/r10k control repository for use with my archlinux_workstation and optionally archlinux_macbookretina Puppet modules. This specific repository includes some personal configuration of mine, and is intended to be forked and modified as described below. This is intended to be a generic framework for anyone who wants to use Puppet to manage their workstation's configuration. The project provides some sane (though opinionated) defaults, and instructions for how to change them. The defaults are geared towards Arch Linux, but the core in this repository can be used for any distribution, or just as an example/starting point.",
6+
"description": "This is an example of a puppet/r10k main repository for use with my archlinux_workstation and optionally archlinux_macbookretina Puppet modules. This specific repository includes some personal configuration of mine, and is intended to be forked and modified. This is intended to be a generic framework for anyone who wants to use Puppet to manage their workstation's configuration. The project provides some sane (though opinionated) defaults, and instructions for how to change them. The defaults are geared towards Arch Linux, but the core in this repository can be used for any distribution, or just as an example/starting point.",
77
"dependencies": [
88
],
99
"operatingsystem_support": [

puppet/config_version.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

puppet/environment.conf

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/spec_helper_local.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
44

55
RSpec.configure do |c|
6-
hieraconf = File.read(File.join(proj_root, 'puppet', 'config', 'hiera.yaml'))
7-
hieraconf.sub!('/etc/puppetlabs/code/workstation-bootstrap/puppet/hiera', File.join(proj_root, 'puppet', 'hiera'))
6+
hieraconf = File.read(File.join(proj_root, 'hiera.yaml.template'))
7+
hieraconf.sub!('%%CLONEDIR%%', proj_root)
88
File.open(File.join(proj_root, 'spec', 'fixtures', 'hiera.yaml'), 'w') { |f| f.write(hieraconf) }
99
c.hiera_config = File.join(proj_root, 'spec', 'fixtures', 'hiera.yaml')
10-
c.manifest = File.join(proj_root, 'puppet', 'manifests', 'site.pp')
10+
c.manifest = File.join(proj_root, 'manifests', 'site.pp')
1111
end
1212

1313
def facts_for_host(ostype, product = 'Unknown')

0 commit comments

Comments
 (0)