From 2d03cd3b3906a708492751c1bbc367f8645ca81f Mon Sep 17 00:00:00 2001 From: Jason Sherman Date: Wed, 6 Jun 2018 20:11:50 -0500 Subject: [PATCH 1/4] Capture work for puppet upgrade --- Vagrantfile | 25 ++++++--- hosts | 7 --- manifests/default.pp | 43 --------------- puppet/data/common.yaml | 52 +++++++++++++++++++ {modules => puppet/data/nodes}/.gitignore | 0 .../environments/local/manifests/twlight.pp | 3 ++ puppet/hiera.yaml | 16 ++++++ puppet/modules/.gitignore | 4 ++ 8 files changed, 93 insertions(+), 57 deletions(-) delete mode 100644 hosts delete mode 100644 manifests/default.pp create mode 100644 puppet/data/common.yaml rename {modules => puppet/data/nodes}/.gitignore (100%) create mode 100644 puppet/environments/local/manifests/twlight.pp create mode 100644 puppet/hiera.yaml create mode 100644 puppet/modules/.gitignore diff --git a/Vagrantfile b/Vagrantfile index 330963e..b0ecd87 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,6 +5,10 @@ twlight_puppet_version = "0.2.13" Vagrant.configure("2") do |config| + # Name this thing + config.vm.define "twlight" + config.vm.hostname = "twlight.vagrant.localdomain" + if File.exists?(File.join(Dir.home, ".gitconfig")) # Read local machine's gitconfig (~/.gitconfig) gitconfig = File.read(File.join(Dir.home, ".gitconfig")) @@ -33,13 +37,15 @@ Vagrant.configure("2") do |config| if Vagrant.has_plugin?("vagrant-vbguest") config.vm.synced_folder ".", "/vagrant", type: "virtualbox", mount_options: ['dmode=777', 'fmode=666'] config.vbguest.auto_update = false - # dump our static hosts file in - config.vm.provision "shell", - inline: "cp /vagrant/hosts /etc/hosts" - # Install puppet because we need it, and vim because the author of this Vagrantfile prefers it + # Install puppet because we need it, chrony because its useful in Vagrant, + # and vim because the author of this Vagrantfile prefers it. config.vm.provision "shell", - inline: "apt-get install -y chrony puppet vim" + inline: "wget --quiet --timestamping --directory-prefix=/tmp \ + https://apt.puppetlabs.com/puppetlabs-release-pc1-jessie.deb && \ + dpkg -i /tmp/puppetlabs-release-pc1-jessie.deb && \ + apt update && apt install -y chrony puppet-agent vim" + # Add github's host key to our known hosts file config.vm.provision "shell", @@ -57,12 +63,17 @@ Vagrant.configure("2") do |config| # Install our twlight puppet module config.vm.provision "shell", - inline: "puppet module install --target-dir /vagrant/modules \ + inline: "puppet module install --target-dir /vagrant/puppet/modules \ jsnshrmn/twlight --version "+ twlight_puppet_version +";" # Run the puppet provisioner config.vm.provision "puppet" do |puppet| - puppet.module_path = "modules" + puppet.working_directory = "/vagrant/puppet" + puppet.hiera_config_path = "puppet/hiera.yaml" + puppet.environment = "local" + puppet.environment_path = "puppet/environments" + puppet.module_path = "puppet/modules" + puppet.binary_path = "/opt/puppetlabs/puppet/bin" # Run migration so any imported DB dump will work with current code. config.vm.provision "shell", diff --git a/hosts b/hosts deleted file mode 100644 index b4156e4..0000000 --- a/hosts +++ /dev/null @@ -1,7 +0,0 @@ -127.0.0.1 localhost twlight.vagrant.localdomain -127.0.1.1 debian-8.7-amd64 debian-8 - -# The following lines are desirable for IPv6 capable hosts -::1 localhost ip6-localhost ip6-loopback -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters diff --git a/manifests/default.pp b/manifests/default.pp deleted file mode 100644 index 58df2b1..0000000 --- a/manifests/default.pp +++ /dev/null @@ -1,43 +0,0 @@ -# The remote git repository that Vagrant will fetch TWLight from. -# Update this to your fork or branch as needed for development. -# To be able to push directly from within Vagrant, use the SSH URI instead of -# HTTPS and make sure your have your SSH key for git added to your key agent. -# You should definitely not try to do that against master. -$twlight_git_repository ='https://github.com/WikipediaLibrary/TWLight.git' -$twlight_git_revision = 'master' - -# The Oauth configuration required to make signin to the site work as expected. -# The 'null' values are not functional. -$twlight_oauth_key = 'null' -$twlight_oauth_secret = 'null' - -# These variables set config values for OS and package configuration as well as -# the app. If you don't know what they are then you don't need to change them. -$twlight_root_dir = '/var/www/html/TWLight' -$twlight_mysqlroot_pw = 'vagrant' -$twlight_mysqltwlight_pw = 'vagrant' -$twlight_restore_file = '/vagrant/backup/twlight.tar.gz' -$twlight_backup_dir = '/vagrant/backup' -$twlight_mysqldump_dir = '/var/www/html/TWLight' -$twlight_servername = 'twlight.vagrant.localdomain' -$twlight_serverport = '80' -$twlight_externalport = '80' -$twlight_environment = 'local' -$twlight_unixname = 'www' -$twlight_mysql_override_options = { - 'mysqld' => { - 'innodb_file_per_table' => '1', - 'innodb_large_prefix' => '1', - 'innodb_file_format' => 'Barracuda', - } -} - -# These variables set config values for the app. -# If you don't know what they are then you don't need to change them. -$twlight_secretkey = 'vagrant' -$twlight_allowedhosts = "['twlight.vagrant.localdomain']" -$twlight_baseurl = "http://${twlight_servername}/" -$twlight_oauth_provider_url = "https://meta.wikimedia.org/w/index.php" - -# Actually calls the module. Don't change this. -class { 'twlight': } diff --git a/puppet/data/common.yaml b/puppet/data/common.yaml new file mode 100644 index 0000000..3b159df --- /dev/null +++ b/puppet/data/common.yaml @@ -0,0 +1,52 @@ +--- +# The remote git repository that Vagrant will fetch TWLight from. +# Update this to your fork or branch as needed for development. +# To be able to push directly from within Vagrant, use the SSH URI instead of +# HTTPS and make sure your have your SSH key for git added to your key agent. +# You should definitely not try to do that against master. +twlight::twlight_git_repository: 'https://github.com/WikipediaLibrary/TWLight.git' +twlight::twlight_git_revision: 'master' + +# These variables set config values for OS and package configuration as well as +# the app. If you don't know what they are then you don't need to change them. +twlight::twlight_root_dir: '/var/www/html/TWLight' +twlight::twlight_mysqlroot_pw: 'vagrant' +twlight::twlight_mysqltwlight_pw: 'vagrant' +twlight::twlight_restore_file: '/vagrant/backup/twlight.tar.gz' +twlight::twlight_backup_dir: '/vagrant/backup' +twlight::twlight_mysqldump_dir: '/var/www/html/TWLight' +twlight::twlight_servername: 'twlight.vagrant.localdomain' +twlight::twlight_serverport: '80' +twlight::twlight_externalport: '80' +twlight::twlight_environment: 'local' +twlight::twlight_unixname: 'www' +# innodb_log_file_size: 128M +# have to change the socket location due to a bug in mariadb_config +twlight::twlight_mysql_override_options: + 'client': + 'socket': '/tmp/mysql.sock', + 'default-character-set': 'utf8mb4', + 'mysqld': + 'socket': '/tmp/mysql.sock', + 'innodb_file_per_table': '1', + 'innodb_large_prefix': '1', + 'innodb_file_format': 'Barracuda', + 'innodb_default_row_format': 'DYNAMIC', + 'innodb_compression_default': '1', + 'innodb_page_size': '64k', + 'collation-server': 'utf8mb4_unicode_ci', + 'init-connect': 'SET NAMES utf8mb4', + 'character-set-server': 'utf8mb4', + 'mysqld_safe': + 'socket': '/tmp/mysql.sock', + 'default-character-set': 'utf8mb4', + +# These variables set config values for the app. +# If you don't know what they are then you don't need to change them. +twlight::twlight_secretkey: 'vagrant' +twlight::twlight_allowedhosts: "['twlight.vagrant.localdomain']" +twlight::twlight_baseurl: "http://${twlight_servername}/" +twlight::twlight_oauth_provider_url: "https://meta.wikimedia.org/w/index.php" + +classes: + - twlight diff --git a/modules/.gitignore b/puppet/data/nodes/.gitignore similarity index 100% rename from modules/.gitignore rename to puppet/data/nodes/.gitignore diff --git a/puppet/environments/local/manifests/twlight.pp b/puppet/environments/local/manifests/twlight.pp new file mode 100644 index 0000000..d551dda --- /dev/null +++ b/puppet/environments/local/manifests/twlight.pp @@ -0,0 +1,3 @@ +node 'twlight.vagrant.localdomain' { + include twlight +} diff --git a/puppet/hiera.yaml b/puppet/hiera.yaml new file mode 100644 index 0000000..d2e8e44 --- /dev/null +++ b/puppet/hiera.yaml @@ -0,0 +1,16 @@ +--- +version: 5 +defaults: + datadir: data + data_hash: yaml_data +hierarchy: + - name: "Per-node data (yaml version)" + path: "nodes/%{trusted.certname}.yaml" # Add file extension. + # Omitting datadir and data_hash to use defaults. + + - name: "Other YAML hierarchy levels" + paths: # Can specify an array of paths instead of one. + - "location/%{facts.whereami}/%{facts.group}.yaml" + - "groups/%{facts.group}.yaml" + - "os/%{facts.os.family}.yaml" + - "common.yaml" diff --git a/puppet/modules/.gitignore b/puppet/modules/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/puppet/modules/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore From 075a806c008fae2af6bfd5f89a7900d72383abd1 Mon Sep 17 00:00:00 2001 From: Jason Sherman Date: Fri, 8 Jun 2018 13:34:55 -0500 Subject: [PATCH 2/4] Cleanup hiera data. --- puppet/data/common.yaml | 55 +++++++++-------------------------------- puppet/hiera.yaml | 2 +- 2 files changed, 13 insertions(+), 44 deletions(-) diff --git a/puppet/data/common.yaml b/puppet/data/common.yaml index 3b159df..5a2e0dc 100644 --- a/puppet/data/common.yaml +++ b/puppet/data/common.yaml @@ -1,52 +1,21 @@ --- -# The remote git repository that Vagrant will fetch TWLight from. -# Update this to your fork or branch as needed for development. -# To be able to push directly from within Vagrant, use the SSH URI instead of -# HTTPS and make sure your have your SSH key for git added to your key agent. -# You should definitely not try to do that against master. -twlight::twlight_git_repository: 'https://github.com/WikipediaLibrary/TWLight.git' -twlight::twlight_git_revision: 'master' - # These variables set config values for OS and package configuration as well as # the app. If you don't know what they are then you don't need to change them. -twlight::twlight_root_dir: '/var/www/html/TWLight' -twlight::twlight_mysqlroot_pw: 'vagrant' -twlight::twlight_mysqltwlight_pw: 'vagrant' -twlight::twlight_restore_file: '/vagrant/backup/twlight.tar.gz' -twlight::twlight_backup_dir: '/vagrant/backup' -twlight::twlight_mysqldump_dir: '/var/www/html/TWLight' -twlight::twlight_servername: 'twlight.vagrant.localdomain' -twlight::twlight_serverport: '80' -twlight::twlight_externalport: '80' -twlight::twlight_environment: 'local' -twlight::twlight_unixname: 'www' -# innodb_log_file_size: 128M -# have to change the socket location due to a bug in mariadb_config -twlight::twlight_mysql_override_options: - 'client': - 'socket': '/tmp/mysql.sock', - 'default-character-set': 'utf8mb4', - 'mysqld': - 'socket': '/tmp/mysql.sock', - 'innodb_file_per_table': '1', - 'innodb_large_prefix': '1', - 'innodb_file_format': 'Barracuda', - 'innodb_default_row_format': 'DYNAMIC', - 'innodb_compression_default': '1', - 'innodb_page_size': '64k', - 'collation-server': 'utf8mb4_unicode_ci', - 'init-connect': 'SET NAMES utf8mb4', - 'character-set-server': 'utf8mb4', - 'mysqld_safe': - 'socket': '/tmp/mysql.sock', - 'default-character-set': 'utf8mb4', +twlight::params::mysqlroot_pw: 'vagrant' +twlight::params::mysqltwlight_pw: 'vagrant' +twlight::params::restore_file: '/vagrant/backup/twlight.tar.gz' +twlight::params::backup_dir: '/vagrant/backup' +twlight::params::servername: 'twlight.vagrant.localdomain' +twlight::params::serverport: '80' +twlight::params::externalport: '80' +twlight::params::environment: 'local' # These variables set config values for the app. # If you don't know what they are then you don't need to change them. -twlight::twlight_secretkey: 'vagrant' -twlight::twlight_allowedhosts: "['twlight.vagrant.localdomain']" -twlight::twlight_baseurl: "http://${twlight_servername}/" -twlight::twlight_oauth_provider_url: "https://meta.wikimedia.org/w/index.php" +twlight::params::secretkey: 'vagrant' +twlight::params::allowedhosts: "['twlight.vagrant.localdomain']" +twlight::params::baseurl: "http://${servername}/" +twlight::params::oauth_provider_url: "https://meta.wikimedia.org/w/index.php" classes: - twlight diff --git a/puppet/hiera.yaml b/puppet/hiera.yaml index d2e8e44..1bc9745 100644 --- a/puppet/hiera.yaml +++ b/puppet/hiera.yaml @@ -1,7 +1,7 @@ --- version: 5 defaults: - datadir: data + datadir: /vagrant/puppet/data data_hash: yaml_data hierarchy: - name: "Per-node data (yaml version)" From 9d6a637c40df6d55e94c4b87a82a8928449a94bb Mon Sep 17 00:00:00 2001 From: Jason Sherman Date: Fri, 8 Jun 2018 16:49:27 -0500 Subject: [PATCH 3/4] Capture work for puppet upgrade --- README.md | 12 ++++++++++-- Vagrantfile | 33 +++++++++++++++++++++------------ puppet/puppet.conf | 2 ++ 3 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 puppet/puppet.conf diff --git a/README.md b/README.md index 29ba121..443101a 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,18 @@ New-Item -ItemType Junction -Path "$env:LOCALAPPDATA\lxss" -Value "$WSLFSPATH\ro Clone this repository, which is where you will be running Vagrant. -You will probably need to tweak some of the settings for the [puppet module](https://github.com/WikipediaLibrary/twlight_puppet); to do so, edit the values in +You will probably need to tweak some of the settings for the [puppet module](https://github.com/WikipediaLibrary/twlight_puppet); to do so, create the following yaml file: ``` -./manifests/default.pp +./puppet/data/nodes/twlight.vagrant.localdomain.yaml ``` +and make sure it contains at least the following (note the three dashes in the first line): +``` +--- +# The Oauth configuration required to make signin to the site work as expected. +twlight::params::oauth_key: 'a valid key given to you by a project member' +twlight::params::oauth_secret: 'a valid secret given to you by a project member' +``` +along with any other parameters you'd like to override, such as the git repository or revision. If you have a tarball that you'd like to load on provision, place it diff --git a/Vagrantfile b/Vagrantfile index b0ecd87..94a04dd 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,7 +1,13 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -twlight_puppet_version = "0.2.13" +#twlight_puppet_version = "0.3.1" +twlight_puppet_version = "master" + +# Put "--debug " in this string if you want to test the limits of your terminal +# emulator's buffer. +twlight_puppet_options = "--confdir /vagrant/puppet --codedir /vagrant/puppet" +twlight_puppet_bin_path = "/opt/puppetlabs/puppet/bin" Vagrant.configure("2") do |config| @@ -52,28 +58,31 @@ Vagrant.configure("2") do |config| inline: "ssh-keyscan -t rsa github.com >> /etc/ssh/ssh_known_hosts" ## Handy method for fetching puppet module from github - #config.vm.provision "shell", - # inline: "wget --quiet --timestamping --directory-prefix=/vagrant/modules \ - # 'https://github.com/WikipediaLibrary/twlight_puppet/archive/"+ twlight_puppet_version +".tar.gz'" + config.vm.provision "shell", + inline: "wget --quiet --timestamping --directory-prefix=/vagrant/puppet/modules \ + 'https://github.com/WikipediaLibrary/twlight_puppet/archive/"+ twlight_puppet_version +".tar.gz'" ## Install our twlight puppet module - #config.vm.provision "shell", - # inline: "puppet module install --target-dir /vagrant/modules \ - # /vagrant/modules/"+ twlight_puppet_version +".tar.gz" + config.vm.provision "shell", + inline: twlight_puppet_bin_path +"/puppet module install \ + "+ twlight_puppet_options +" --target-dir /vagrant/puppet/modules \ + /vagrant/puppet/modules/"+ twlight_puppet_version +".tar.gz" # Install our twlight puppet module - config.vm.provision "shell", - inline: "puppet module install --target-dir /vagrant/puppet/modules \ - jsnshrmn/twlight --version "+ twlight_puppet_version +";" + #config.vm.provision "shell", + # inline: twlight_puppet_bin_path +"/puppet module install \ + # "+ twlight_puppet_options +" --target-dir /vagrant/puppet/modules \ + # jsnshrmn/twlight --version "+ twlight_puppet_version +";" # Run the puppet provisioner config.vm.provision "puppet" do |puppet| puppet.working_directory = "/vagrant/puppet" puppet.hiera_config_path = "puppet/hiera.yaml" - puppet.environment = "local" + puppet.environment = "local" # Obviously a lie, but couldn't get the whole puppet stack to believe otherwise puppet.environment_path = "puppet/environments" puppet.module_path = "puppet/modules" - puppet.binary_path = "/opt/puppetlabs/puppet/bin" + puppet.binary_path = twlight_puppet_bin_path + puppet.options = twlight_puppet_options # Run migration so any imported DB dump will work with current code. config.vm.provision "shell", diff --git a/puppet/puppet.conf b/puppet/puppet.conf new file mode 100644 index 0000000..be3b7db --- /dev/null +++ b/puppet/puppet.conf @@ -0,0 +1,2 @@ +[main] +environment = local From 6cdea355c5dc77b82dc7bf56e91818ad5a2cea10 Mon Sep 17 00:00:00 2001 From: Jason Sherman Date: Sat, 9 Jun 2018 20:46:50 -0500 Subject: [PATCH 4/4] Cleanup for puppet 4.10.x compatible module. --- README.md | 4 ++-- Vagrantfile | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 443101a..66e38da 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ New-Item -ItemType Junction -Path "$env:LOCALAPPDATA\lxss" -Value "$WSLFSPATH\ro Clone this repository, which is where you will be running Vagrant. -You will probably need to tweak some of the settings for the [puppet module](https://github.com/WikipediaLibrary/twlight_puppet); to do so, create the following yaml file: +You will need to configure some of the settings for the [puppet module](https://github.com/WikipediaLibrary/twlight_puppet); to do so, create the following yaml file: ``` ./puppet/data/nodes/twlight.vagrant.localdomain.yaml ``` @@ -60,7 +60,7 @@ and make sure it contains at least the following (note the three dashes in the f twlight::params::oauth_key: 'a valid key given to you by a project member' twlight::params::oauth_secret: 'a valid secret given to you by a project member' ``` -along with any other parameters you'd like to override, such as the git repository or revision. +along with any other parameters you'd like to override, such as the git repository or revision. See the [parameters manifest in the puppet module](https://github.com/WikipediaLibrary/twlight_puppet/blob/master/manifests/params.pp). If you have a tarball that you'd like to load on provision, place it diff --git a/Vagrantfile b/Vagrantfile index 94a04dd..fad6380 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,8 +1,8 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -#twlight_puppet_version = "0.3.1" -twlight_puppet_version = "master" +twlight_puppet_version = "0.3.2" +#twlight_puppet_version = "master" # Put "--debug " in this string if you want to test the limits of your terminal # emulator's buffer. @@ -58,27 +58,27 @@ Vagrant.configure("2") do |config| inline: "ssh-keyscan -t rsa github.com >> /etc/ssh/ssh_known_hosts" ## Handy method for fetching puppet module from github - config.vm.provision "shell", - inline: "wget --quiet --timestamping --directory-prefix=/vagrant/puppet/modules \ - 'https://github.com/WikipediaLibrary/twlight_puppet/archive/"+ twlight_puppet_version +".tar.gz'" - - ## Install our twlight puppet module - config.vm.provision "shell", - inline: twlight_puppet_bin_path +"/puppet module install \ - "+ twlight_puppet_options +" --target-dir /vagrant/puppet/modules \ - /vagrant/puppet/modules/"+ twlight_puppet_version +".tar.gz" + #config.vm.provision "shell", + # inline: "wget --quiet --timestamping --directory-prefix=/vagrant/puppet/modules \ + # 'https://github.com/WikipediaLibrary/twlight_puppet/archive/"+ twlight_puppet_version +".tar.gz'" - # Install our twlight puppet module + ## Install our twlight puppet module from github #config.vm.provision "shell", # inline: twlight_puppet_bin_path +"/puppet module install \ # "+ twlight_puppet_options +" --target-dir /vagrant/puppet/modules \ - # jsnshrmn/twlight --version "+ twlight_puppet_version +";" + # /vagrant/puppet/modules/"+ twlight_puppet_version +".tar.gz" + + # Install our twlight puppet module from puppet forge + config.vm.provision "shell", + inline: twlight_puppet_bin_path +"/puppet module install \ + "+ twlight_puppet_options +" --target-dir /vagrant/puppet/modules \ + jsnshrmn/twlight --version "+ twlight_puppet_version +";" # Run the puppet provisioner config.vm.provision "puppet" do |puppet| puppet.working_directory = "/vagrant/puppet" puppet.hiera_config_path = "puppet/hiera.yaml" - puppet.environment = "local" # Obviously a lie, but couldn't get the whole puppet stack to believe otherwise + puppet.environment = "local" puppet.environment_path = "puppet/environments" puppet.module_path = "puppet/modules" puppet.binary_path = twlight_puppet_bin_path