diff --git a/Gemfile b/Gemfile index 464c756..7ed29a0 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,7 @@ group :production do gem 'puppet', puppetversion gem 'r10k', '~> 2.3' gem 'rugged', '~> 0.24' + gem 'xmlrpc', '~> 0.3.0' end group :development, :unit_tests do diff --git a/Gemfile.lock b/Gemfile.lock index 27c69a5..b551703 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,6 +145,7 @@ GEM wisper (~> 1.6.1) unicode-display_width (1.2.1) wisper (1.6.1) + xmlrpc (0.3.0) yamllint (0.0.9) trollop (~> 2) @@ -178,6 +179,7 @@ DEPENDENCIES tty-command (~> 0.4) tty-file (~> 0.3) tty-prompt (~> 0.12) + xmlrpc (~> 0.3.0) yamllint (~> 0.0.9) BUNDLED WITH diff --git a/README.md b/README.md index 9730375..fc5845b 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,21 @@ My dot files and a tool to deploy them to various OS's ```bash git clone git@github.com:genebean/dots.git ~/.dotfiles cd ~/.dotfiles -bundle install -bundle exec r10k puppetfile install --puppetfile ~/.dotfiles/production/puppet/Puppetfile -v +bin/bootstrap.sh +This script takes care of getting dots ready to use +Enter the number of the task you want to perform: +1) Mac setup +2) EL setup +3) Quit +Task: ``` #### Running Puppet ```bash +# Any of these will work: +bundle exec rake dots:run_puppet +bundle exec rake dots:run_puppet_noop bundle exec puppet apply --environmentpath ~/.dotfiles/puppet ~/.dotfiles/puppet/production/manifests/site.pp ``` @@ -68,9 +76,9 @@ cd ~/repos/powerline-fonts ##### Thoughts on installing with Puppet: -* install packages using a provider for homebrew -* install packages using the pip provider -* use vcsrepo to clone the fonts -* create a refresh-only exec that runs the install script -* add a notify to the vcsrepo resource that triggers the exec +* [x] install packages using a provider for homebrew +* [ ] install packages using the pip provider +* [ ] use vcsrepo to clone the fonts +* [ ] create a refresh-only exec that runs the install script +* [ ] add a notify to the vcsrepo resource that triggers the exec * this will also take care of bringing in new fonts or updates diff --git a/Rakefile b/Rakefile index c46690b..1cb3edb 100644 --- a/Rakefile +++ b/Rakefile @@ -65,6 +65,11 @@ task :tests do Rake::Task[:spec].invoke end +desc 'Run dots' +task :dots do + ruby 'bin/dots.rb' +end + namespace 'dots' do cmd = TTY::Command.new @@ -82,4 +87,12 @@ namespace 'dots' do ~/.dotfiles/puppet/production/manifests/site.pp' cmd.run(command) end + + desc 'Run Puppet (noop)' + task :run_puppet_noop do + command = 'bundle exec puppet apply \ + --environmentpath ~/.dotfiles/puppet \ + ~/.dotfiles/puppet/production/manifests/site.pp --noop' + cmd.run(command) + end end diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh new file mode 100755 index 0000000..20e0cbe --- /dev/null +++ b/bin/bootstrap.sh @@ -0,0 +1,24 @@ +#!/bin/bash +echo 'This script takes care of getting dots ready to use' +echo 'Enter the number of the task you want to perform:' + +PS3='Task: ' +select TASK in 'Mac setup' 'EL setup' 'Quit'; +do + case $TASK in + 'Mac setup' ) + ~/.dotfile/bin/bootstrap/bootstrap_mac.sh now + ;; + 'EL setup' ) + ~/.dotfile/bin/bootstrap/bootstrap_el.sh now + ;; + 'Quit' ) + echo 'Exiting' + exit 0 + ;; + * ) + echo 'Invalid selection, quitting.' + exit 1 + ;; + esac +done diff --git a/bin/bootstrap/bootstrap_mac.sh b/bin/bootstrap/bootstrap_mac.sh new file mode 100755 index 0000000..2c27ff8 --- /dev/null +++ b/bin/bootstrap/bootstrap_mac.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [[ $1 == 'now' ]]; then + # Install Homebrew + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + + # Install dot's dependencies + /usr/local/bin/brew install ruby cmake pkg-config + /usr/local/bin/gem install --no-ri --no-rdoc bundler + + # Make dot usable + cd ~/.dotfiles + /usr/local/bin/bundle install + + # Install Puppet modules + /usr/local/bin/bundle exec rake dots:run_r10k + + # Display tasks that can be run + echo 'These are the task that can now be executed:' + /usr/local/bin/bundle exec rake -T |grep --color=never 'rake dots' +fi diff --git a/puppet/production/Puppetfile b/puppet/production/Puppetfile index ff7e84d..077481a 100644 --- a/puppet/production/Puppetfile +++ b/puppet/production/Puppetfile @@ -1,9 +1,12 @@ # rubocop:disable FileName forge 'http://forge.puppetlabs.com' +# rubocop:disable Metrics/LineLength # The next line translates to '../../vendor/puppet_modules' aka ~/.dotfiles/vendor/puppet_modules moduledir "#{File.dirname(File.dirname(File.dirname(__FILE__)))}/vendor/puppet_modules" +# rubocop:enable Metrics/LineLength -mod 'homebrew', - :git => 'https://github.com/boxen/puppet-homebrew.git' mod 'puppetlabs-vcsrepo', '1.5.0' +mod 'thekevjames-homebrew', + git: 'https://github.com/genebean/puppet-homebrew.git', + branch: 'non-root-and-bundler' diff --git a/puppet/production/environment.conf b/puppet/production/environment.conf index d73df3b..e913156 100644 --- a/puppet/production/environment.conf +++ b/puppet/production/environment.conf @@ -1,2 +1,2 @@ -modulepath = modules:site:$basemodulepath -config_version = 'scripts/config_version.sh $environmentpath $environment' +modulepath = modules:site:~/.dotfiles/vendor/puppet_modules:$basemodulepath +config_version = 'scripts/config_version.sh $environmentpath' diff --git a/puppet/production/manifests/site.pp b/puppet/production/manifests/site.pp index 7fa91bf..c6844c2 100644 --- a/puppet/production/manifests/site.pp +++ b/puppet/production/manifests/site.pp @@ -10,3 +10,7 @@ node default { notify{'This is from the default node.':} } + +node 'dawns-macbook-pro.local' { + include ::profile::mac +} diff --git a/puppet/production/scripts/config_version.sh b/puppet/production/scripts/config_version.sh index bc77213..ff38958 100755 --- a/puppet/production/scripts/config_version.sh +++ b/puppet/production/scripts/config_version.sh @@ -1,12 +1,5 @@ #!/bin/bash -if [ -e $1/$2/.r10k-deploy.json ] -then - /opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/code_manager_config_version.rb $1 $2 -elif [ -e /opt/puppetlabs/server/pe_version ] -then - /opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2 -else - /usr/bin/git --version > /dev/null 2>&1 && - /usr/bin/git --git-dir $1/$2/.git rev-parse HEAD || - date +%s -fi + +/usr/bin/git --version > /dev/null 2>&1 && +/usr/bin/git --git-dir $1/../.git rev-parse HEAD || +date +%s diff --git a/puppet/production/site/profile/manifests/mac.pp b/puppet/production/site/profile/manifests/mac.pp new file mode 100644 index 0000000..124b740 --- /dev/null +++ b/puppet/production/site/profile/manifests/mac.pp @@ -0,0 +1,46 @@ +# this contains the mac specific stuff +class profile::mac { + # $path = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin' + # notify{'This is from the mac profile.':} + # exec { 'install homebrew': + # command => '/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"', + # path => $path, + # creates => '/usr/local/bin/brew', + # } + + #Package { provider => 'homebrew' } + $homebrew_packages = [ + 'bash-completion', + 'bundler-completion', + 'cmake', + 'coreutils', + 'docker-completion', + 'elixir', + 'erlang', + 'figlet', + 'git', + 'git-flow', + 'gnu-tar', + 'hub', + 'iftop', + 'mutt', + 'packer', + 'python', + 'ruby', + 'sl', + 'socat', + 'tmux', + 'tree', + 'unrar', + 'vagrant-completion', + 'watch', + 'wget', + 'zsh', + 'zsh-completions', + ] + + package { $homebrew_packages: + ensure => installed, + provider => 'brew', + } +}