How do I deploy the r10k-webhook with puppet the module?

74 Views Asked by At

I'm following this module puppet-r10k for deploying a r10k environment setup.

My configuration is the following:

node 'puppet-,master.example.com' {
  class { 'r10k':
    sources => {
      'puppet' => {
        'remote'  => '[email protected]:puppet/control-repository.git',
        'basedir' => "${::settings::codedir}/environments",
        'prefix'  => false,
      },
    },
  }

  class { 'r10k::webhook':
    ensure => true,
    server => {
      protected => false,
    },
  }
}

So as you can see I did a setup of the r10k itself and a webhook. Now the problem is the webhook (which I don't really understand how it works). It creates two files:

root@puppet-master:~# cat /etc/voxpupuli/webhook.yml
---
server:
  protected: false
chatops:
  enabled: false
  service:
  channel:
  user:
  auth_token:
  server_uri:
r10k:
  command_path: "/opt/puppetlabs/puppet/bin/r10k"
  config_path: "/etc/puppetlabs/r10k/r10k.yaml"
  default_branch: production
  prefix:
  allow_uppercase: false
  verbose: true
  deploy_modules: true
  generate_types: true



root@puppet-master:~# cat /etc/puppetlabs/r10k/r10k.yaml
---
pool_size: 2
deploy:
  generate_types: true
  exclude_spec: true
cachedir: "/opt/puppetlabs/puppet/cache/r10k"
sources:
  puppet:
    remote: [email protected]:puppet/control-repository.git
    basedir: "/etc/puppetlabs/code/environments"
    prefix: false

Now, on my gitlab server (192.168.1.50) I added a new webhook with a URL: http://192.168.1.52:8088/payload but I get the error

Hook execution failed: Failed to open TCP connection to 192.168.1.52:8088 (Connection refused - connect(2) for "192.168.1.52" port 8088)

Is there anything I missed? Is there anything I should do first?

Thanks for helping :)

1

There are 1 best solutions below

2
Arnau Bria On BEST ANSWER

I'm struggling with this, too. Using version 11 of the module and puppet 7.

For gems to install, I had to run the commands manually:

/opt/puppetlabs/puppet/bin/gem install r10k -v 4.0.1
/opt/puppetlabs/puppet/bin/gem install faraday-net_http -v 3.0.2
/opt/puppetlabs/puppet/bin/gem install faraday -v 2.8.1

dont' ask me why, but puppet could not install it running the same command.

Make sure you have webhook service runnig? (called webhook-go). Again, the module tries to star a service called webhook and not webhook-go. And it listens on port 4000 and not 8088.

conf /etc/voxpupuli/webhook.yml

server:
  protected: false
chatops:
  enabled: false
  service:
  server_uri:
  user:
  channel:
  auth_token:
r10k:
  command_path: "/opt/puppetlabs/puppet/bin/r10k"
  config_path: "/etc/puppetlabs/r10k/r10k.yaml"
  default_branch: production
  prefix:
  allow_uppercase: false
  verbose: true
  deploy_modules: true
  generate_types: true

conf: /etc/puppetlabs/r10k/r10k.yaml

---
:cachedir: /opt/puppetlabs/puppet/cache/r10k
:sources:
  puppet:
    basedir: /etc/puppetlabs/code/environments
    prefix: false
    remote: git@gitlabserverurl:repo/puppet7.git

:pool_size: 8

add this url in the webhook (gitlab with no auth):

http://puppet-server.domain.com:4000/api/v1/r10k/environment

and that should make it work (also had to change some gitlab conf based on https://gitlab.com/gitlab-org/gitlab/-/issues/26845

HTH