Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vagrant-r10k support for oscar #37

Open
tribou opened this issue Dec 31, 2014 · 2 comments
Open

Vagrant-r10k support for oscar #37

tribou opened this issue Dec 31, 2014 · 2 comments

Comments

@tribou
Copy link

tribou commented Dec 31, 2014

Is there an easy way to integrate vagrant-r10k with oscar? Tried using the following in the config/roles.yaml:

---
roles:
  pe-puppet-master:
    r10k:
      puppet_dir: "puppet"
      puppetfile_path: "puppet/Puppetfile"
      module_path: "puppet/vendor"

Returns the following error on a vagrant up/provision:

master: vagrant-r10k: puppet_dir and/or puppetfile_path not set in config; not running

From vagrant debug:

 INFO warden: Calling IN action: #<VagrantPlugins::R10k::Modulegetter:0x0000000390bc28>
 INFO interface: detail: vagrant-r10k: puppet_dir and/or puppetfile_path not set in config; not running
 INFO interface: detail:     master: vagrant-r10k: puppet_dir and/or puppetfile_path not set in config; not running
    master: vagrant-r10k: puppet_dir and/or puppetfile_path not set in config; not running
 INFO warden: Calling IN action: #<Vagrant::Action::Builtin::ConfigValidate:0x0000000390bc00>

It may be that the vagrant-config_builder is simply not pulling in the defined vagrant-r10k configs.

The goal is to use oscar with r10k to build out a local dev environment and enable local development and testing of locally stored puppet modules.

@jantman
Copy link

jantman commented Dec 31, 2014

Ok, sorry, my last comment made about 25% of the sense it should've.

It would make much more sense to me to have Oscar do what vagrant-r10k does, itself. Especially since both projects have the same maintainer. vagrant-r10k implements a very limited set of the r10k functionality, but @adrienthebo, you're more than welcome to steal code from it, or outright obsolete it.

@walterheck
Copy link

We implemented this ghetto style in the roles.yaml file:

---
roles:
  pe-puppet-master:
    provider:
      type: virtualbox
      customize:
        - [modifyvm, !ruby/sym id, '--memory', 8192]
    provisioners:
      -
        type: hosts
        add_localhost_hostnames: false
        sync_hosts: true
      - type: shell
        inline: |-
          /bin/systemctl stop firewalld
      -
        type: pe_bootstrap
        role: !ruby/sym master
      -
        type: shell
        inline: |-
          /usr/local/bin/puppet module install zack-r10k
          /usr/local/bin/puppet module install abrader-gms
          /usr/local/bin/puppet apply /vagrant/manifests/r10k_installation.pp
          /usr/local/bin/r10k deploy environment -pv 
          /bin/echo '==> puppet config set hiera_config /etc/puppetlabs/code/environments/production/hiera.yaml'
          /usr/local/bin/puppet config set hiera_config /etc/puppetlabs/code/environments/production/hiera.yaml
          /bin/echo '==> /bin/systemctl restart pe-puppetserver'
          /bin/systemctl restart pe-puppetserver
          /bin/echo '==> /usr/local/bin/puppet agent -t'
          /usr/local/bin/puppet agent -t || true
          /sbin/service puppet stop

in config/vms.yaml:

---
vms:
## puppet master
- name: master
  box: puppetlabs/centos-7.0-64-nocm
  private_networks: [ {ip: '10.20.1.10'} ]
  hostname: master.olindata.vm
  roles:
  - pe-puppet-master

and the manifests/r10k_installation.pp looks like this:

exec { 'create-ssh-key':
  command => 'yes y | ssh-keygen -t dsa -C "r10k" -f /root/.ssh/id_dsa -q -N ""',
  path    => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
  creates => '/root/.ssh/id_dsa.pub',
} ->

#https://docs.puppetlabs.com/references/latest/type.html#sshkey
sshkey { "github.com":
  ensure => present,
  type   => "ssh-rsa",
  target => "/root/.ssh/known_hosts",
  key    => ssh-pub-key=="
} ->

# https://github.com/abrader/abrader-gms
git_deploy_key { 'add_deploy_key_to_puppet_control':
  ensure       => present,
  name         => $::fqdn,  
  path         => '/root/.ssh/id_dsa.pub',
  token        => '<<GITHUB_API_TOKEN_HERE>>',
  project_name => 'yourorga/some-control',
  server_url   => 'https://api.github.com',
  provider     => 'github',
} ->

class { 'r10k':
  configfile => '/etc/puppetlabs/r10k/r10k.yaml',
  sources    => {
    'puppet'    => {
      'remote'  => '[email protected]:yourorga/some-control.git',
      'basedir' => "${::settings::environmentpath}",
      'prefix'  => false,
    }
  },
}

That gives you a fully self-provisioning master without any manual steps. Only downside is the github apikey that is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants