Module: Arfor::ControlRepo
- Defined in:
- lib/arfor/control_repo.rb
Constant Summary collapse
- WORKING_DIR =
'puppet-control'- UPSTREAM_EXAMPLE =
'https://github.com/puppetlabs/control-repo'- CLEANUP_FILES =
[ 'README.md', 'LICENSE', 'site/role/manifests/database_server.pp', 'site/role/manifests/web_server.pp', 'site/role/manifests/database_server.pp', 'site/role/manifests/example.pp', 'site/profile/manifests/example.pp', ]
- VENDORED_FILES =
'../../res/control_repo/.'- CLEAN_RUBY =
"unset RUBYLIB GEM_HOME GEM_PATH RUBYOPT BUNDLE_GEMFILE; "
Class Method Summary collapse
-
.create ⇒ Object
create a new contorl repository in a directory ./puppet-control.
Class Method Details
.create ⇒ Object
create a new contorl repository in a directory ./puppet-control
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/arfor/control_repo.rb', line 35 def self.create() if File.exists?(WORKING_DIR) abort("Puppet control repository already exists at #{WORKING_DIR}") else # Step 1 - git clone of upstream puppet control repository system("git clone #{UPSTREAM_EXAMPLE} #{WORKING_DIR}") # Step 2 - crud cleanup CLEANUP_FILES.each { |f| # swallow errors relating to files that are no longer in upstream begin File.delete(f) rescue end } # ...And remove upstream git repo - not needed FileUtils.rm_rf(File.join(WORKING_DIR, '.git')) # Step 3 - Copy in files dir = File.join(File.dirname(File.(__FILE__)), VENDORED_FILES) FileUtils.cp_r(dir, WORKING_DIR) # Step 4 - Install onceover Dir.chdir(WORKING_DIR) { system("#{CLEAN_RUBY} bundle install") system("#{CLEAN_RUBY} bundle exec onceover init") # Step 5 - setup git system("git init") system("git checkout -b production") # Step 6 - initial git commit system("git add -A") system("git commit -m 'initial' ") } end end |