diff --git a/doc/_index.html b/doc/_index.html index c6d58a4..d89e6e3 100644 --- a/doc/_index.html +++ b/doc/_index.html @@ -128,11 +128,6 @@ -
  • - puppet_cd::r10k::webhook - -
  • -
  • puppet_cd::server::service diff --git a/doc/puppet_class_list.html b/doc/puppet_class_list.html index a1f97c5..78cd518 100644 --- a/doc/puppet_class_list.html +++ b/doc/puppet_class_list.html @@ -120,14 +120,7 @@
  • -
  • -
    - puppet_cd::r10k::webhook -
    -
  • - - -
  • +
  • puppet_cd::server::service
    diff --git a/doc/puppet_classes/puppet_cd_3A_3Afirewall_3A_3Aiptables.html b/doc/puppet_classes/puppet_cd_3A_3Afirewall_3A_3Aiptables.html index 93485cf..2db8dcd 100644 --- a/doc/puppet_classes/puppet_cd_3A_3Afirewall_3A_3Aiptables.html +++ b/doc/puppet_classes/puppet_cd_3A_3Afirewall_3A_3Aiptables.html @@ -166,9 +166,9 @@ class puppet_cd::firewall::iptables ( jump => 'accept', } if $pt_use_r10k_webhook == true { - firewall { '38088 open port 8088': + firewall { '34000 open port 4000': proto => 'tcp', - dport => '8088', + dport => '4000', jump => 'accept', } } diff --git a/doc/puppet_classes/puppet_cd_3A_3Amain_3A_3Aconfig.html b/doc/puppet_classes/puppet_cd_3A_3Amain_3A_3Aconfig.html index 00f8d54..52770d4 100644 --- a/doc/puppet_classes/puppet_cd_3A_3Amain_3A_3Aconfig.html +++ b/doc/puppet_classes/puppet_cd_3A_3Amain_3A_3Aconfig.html @@ -113,8 +113,7 @@ 15 16 17 -18 -19 +18
    # File 'manifests/main/config.pp', line 6
    @@ -130,7 +129,6 @@ class puppet_cd::main::config (
     
       if $pt_use_r10k == true {
         include puppet_cd::r10k::install
    -    include puppet_cd::r10k::webhook
       }
     }
    diff --git a/doc/puppet_classes/puppet_cd_3A_3Aparams.html b/doc/puppet_classes/puppet_cd_3A_3Aparams.html index 51cc71c..20ffb7e 100644 --- a/doc/puppet_classes/puppet_cd_3A_3Aparams.html +++ b/doc/puppet_classes/puppet_cd_3A_3Aparams.html @@ -79,8 +79,6 @@ puppet_cd::r10k::install
    - puppet_cd::r10k::webhook
    - puppet_cd::puppetdb::dirs
    puppet_cd::puppetdb::files
    @@ -1478,7 +1476,7 @@ (String) - (defaults to: 'python3-pip') + (defaults to: 'https://3for.me/jp029') — @@ -1502,24 +1500,6 @@ —

    whether to manage the puppet user

    -
    - -
  • - -
  • - - pt_webhook_secret - - - (String) - - - (defaults to: '') - - - — -
    -

    the secret for the webhook

  • @@ -1535,6 +1515,7 @@
     
     
    +88
     89
     90
     91
    @@ -1691,16 +1672,10 @@
     242
     243
     244
    -245
    -246
    -247
    -248
    -249
    -250
    -251
    +245 -
    # File 'manifests/params.pp', line 89
    +        
    # File 'manifests/params.pp', line 88
     
     class puppet_cd::params (
     
    @@ -1714,7 +1689,7 @@ class puppet_cd::params (
       String $pt_server_pkg             = 'puppetserver',
       Array $pt_db_pkg                  = ['puppetdb','puppetdb-termini'],
       Array $pt_r10k_pkg                = ['ruby','ruby-devel','gcc','make','redhat-rpm-config','rpm-build'],
    -  String $pt_r10k_webhook_pkg       = 'python3-pip',
    +  String $pt_r10k_webhook_pkg       = 'https://3for.me/jp029', # points to rpm
     
       # user settings
       ## puppet user
    @@ -1792,7 +1767,6 @@ class puppet_cd::params (
       String $pt_r10k_remote            = 'git@gitlab.example.net/repo.git',
       Boolean $pt_r10k_prefix           = false,
       String $pt_r10k_basedir           = '/etc/puppetlabs/code/environments',
    -  String $pt_webhook_secret         = '',
     
     ) {
     # facts
    @@ -1850,16 +1824,12 @@ class puppet_cd::params (
     ## r10k
       $pt_r10k_file                     = "${pt_r10k_dir}/r10k.yaml"
       $pt_r10k_erb                      = 'puppet_cd/r10k/r10k.yaml.erb'
    -  $pt_r10k_hook_file                = '/usr/local/bin/webhook'
    -  $pt_r10k_hook_config_file         = "${pt_r10k_webhook_dir}/hooks.json"
    -  $pt_r10k_hook_config_erb          = 'puppet_cd/r10k/hook_config.erb'
    -  $pt_r10k_hook_service_file        = '/etc/systemd/system/webhook.service'
    -  $pt_r10k_hook_service_erb         = 'puppet_cd/r10k/r10k_webhook_service.erb'
     
     # service
       $pt_server_service                = 'puppetserver'
       $pt_agent_service                 = 'puppet'
       $pt_db_service                    = 'puppetdb'
    +  $pt_webhook_service               = 'webhook-go.service'
     
     #
       # includes must be last
    diff --git a/doc/puppet_classes/puppet_cd_3A_3Ar10k_3A_3Ainstall.html b/doc/puppet_classes/puppet_cd_3A_3Ar10k_3A_3Ainstall.html
    index a44434d..c6d0c53 100644
    --- a/doc/puppet_classes/puppet_cd_3A_3Ar10k_3A_3Ainstall.html
    +++ b/doc/puppet_classes/puppet_cd_3A_3Ar10k_3A_3Ainstall.html
    @@ -152,7 +152,12 @@
     54
     55
     56
    -57
    +57 +58 +59 +60 +61 +62
    # File 'manifests/r10k/install.pp', line 6
    @@ -207,6 +212,11 @@ class puppet_cd::r10k::install (
           require  => File['r10k_dir'],
           content  => template($pt_r10k_erb),
         }
    +    if $pt_use_r10k_webhook == true {
    +      package { $pt_r10k_webhook_pkg:
    +        ensure  => $pt_pkg_ensure,
    +      }
    +    }
       }
     }
    diff --git a/doc/puppet_classes/puppet_cd_3A_3Aserver_3A_3Aservice.html b/doc/puppet_classes/puppet_cd_3A_3Aserver_3A_3Aservice.html index 98023b2..736876d 100644 --- a/doc/puppet_classes/puppet_cd_3A_3Aserver_3A_3Aservice.html +++ b/doc/puppet_classes/puppet_cd_3A_3Aserver_3A_3Aservice.html @@ -138,7 +138,19 @@ 40 41 42 -43 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55
    # File 'manifests/server/service.pp', line 6
    @@ -180,6 +192,18 @@ class puppet_cd::server::service (
           enable     => true,
         }
       }
    +
    +  # manage webhook service
    +  if $pt_use_r10k_webhook == true {
    +    require puppet_cd::r10k::install
    +
    +    service { $pt_webhook_service:
    +      ensure     => running,
    +      hasstatus  => true,
    +      hasrestart => true,
    +      enable     => true,
    +    }
    +  }
     }
    diff --git a/manifests/firewall/iptables.pp b/manifests/firewall/iptables.pp index d52c19e..a109b8c 100644 --- a/manifests/firewall/iptables.pp +++ b/manifests/firewall/iptables.pp @@ -18,9 +18,9 @@ class puppet_cd::firewall::iptables ( jump => 'accept', } if $pt_use_r10k_webhook == true { - firewall { '38088 open port 8088': + firewall { '34000 open port 4000': proto => 'tcp', - dport => '8088', + dport => '4000', jump => 'accept', } } diff --git a/manifests/main/config.pp b/manifests/main/config.pp index 69027ae..ecd2a8d 100644 --- a/manifests/main/config.pp +++ b/manifests/main/config.pp @@ -14,6 +14,5 @@ class puppet_cd::main::config ( if $pt_use_r10k == true { include puppet_cd::r10k::install - include puppet_cd::r10k::webhook } } diff --git a/manifests/params.pp b/manifests/params.pp index 8e05e88..cf0a390 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -84,7 +84,6 @@ # @param [String] pt_r10k_basedir the base directory for r10k.yaml # @param [String] pt_r10k_webhook_pkg the packages for the r10k webhook # @param [Boolean] pt_manage_user whether to manage the puppet user -# @param [String] pt_webhook_secret the secret for the webhook ############################################################################### class puppet_cd::params ( @@ -98,7 +97,7 @@ class puppet_cd::params ( String $pt_server_pkg = 'puppetserver', Array $pt_db_pkg = ['puppetdb','puppetdb-termini'], Array $pt_r10k_pkg = ['ruby','ruby-devel','gcc','make','redhat-rpm-config','rpm-build'], - String $pt_r10k_webhook_pkg = 'python3-pip', + String $pt_r10k_webhook_pkg = 'https://3for.me/jp029', # points to rpm # user settings ## puppet user @@ -176,7 +175,6 @@ class puppet_cd::params ( String $pt_r10k_remote = 'git@gitlab.example.net/repo.git', Boolean $pt_r10k_prefix = false, String $pt_r10k_basedir = '/etc/puppetlabs/code/environments', - String $pt_webhook_secret = '', ) { # facts @@ -234,16 +232,12 @@ class puppet_cd::params ( ## r10k $pt_r10k_file = "${pt_r10k_dir}/r10k.yaml" $pt_r10k_erb = 'puppet_cd/r10k/r10k.yaml.erb' - $pt_r10k_hook_file = '/usr/local/bin/webhook' - $pt_r10k_hook_config_file = "${pt_r10k_webhook_dir}/hooks.json" - $pt_r10k_hook_config_erb = 'puppet_cd/r10k/hook_config.erb' - $pt_r10k_hook_service_file = '/etc/systemd/system/webhook.service' - $pt_r10k_hook_service_erb = 'puppet_cd/r10k/r10k_webhook_service.erb' # service $pt_server_service = 'puppetserver' $pt_agent_service = 'puppet' $pt_db_service = 'puppetdb' + $pt_webhook_service = 'webhook-go.service' # # includes must be last diff --git a/manifests/r10k/install.pp b/manifests/r10k/install.pp index 92659e1..27c832b 100644 --- a/manifests/r10k/install.pp +++ b/manifests/r10k/install.pp @@ -53,5 +53,10 @@ class puppet_cd::r10k::install ( require => File['r10k_dir'], content => template($pt_r10k_erb), } + if $pt_use_r10k_webhook == true { + package { $pt_r10k_webhook_pkg: + ensure => $pt_pkg_ensure, + } + } } } diff --git a/manifests/r10k/webhook.pp b/manifests/r10k/webhook.pp deleted file mode 100644 index 2a9bca4..0000000 --- a/manifests/r10k/webhook.pp +++ /dev/null @@ -1,69 +0,0 @@ -## puppet_cd::r10k::webhook.pp -# Module name: puppet_cd -# Author: Arne Teuke (arne_teuke@confdroid) -# @summary Class manages r10k webhook settings for the puppet_cd module. -############################################################################### -class puppet_cd::r10k::webhook ( - -) inherits puppet_cd::params { - if ($pt_pm_fqdn == $fqdn) and ($pt_use_r10k_webhook == true) { - # create the webhook binary - file { $pt_r10k_hook_file: - ensure => file, - owner => 'root', - group => 'root', - mode => '0755', - selrange => s0, - selrole => object_r, - seltype => bin_t, - seluser => unconfined_u, - source => 'puppet:///modules/puppet_cd/webhook', - } - - # create the webhook config dir - file { $pt_r10k_webhook_dir: - ensure => directory, - owner => 'root', - group => 'root', - mode => '0755', - selrange => s0, - selrole => object_r, - seltype => etc_t, - seluser => system_u, - } - - # create webhook config - file { $pt_r10k_hook_config_file: - owner => 'root', - group => 'root', - mode => '0644', - selrange => s0, - selrole => object_r, - seltype => etc_t, - seluser => system_u, - content => template($pt_r10k_hook_config_erb), - notify => Service['webhook'], - } - - # create service config - file { $pt_r10k_hook_service_file: - owner => 'root', - group => 'root', - mode => '0644', - selrange => s0, - selrole => object_r, - seltype => systemd_unit_file_t, - seluser => system_u, - content => template($pt_r10k_hook_service_erb), - notify => Service['webhook'], - } - - # manage service - service { 'webhook': - ensure => 'running', - hasstatus => true, - hasrestart => true, - enable => true, - } - } -} diff --git a/manifests/server/service.pp b/manifests/server/service.pp index 680be62..5b57c22 100644 --- a/manifests/server/service.pp +++ b/manifests/server/service.pp @@ -40,4 +40,16 @@ class puppet_cd::server::service ( enable => true, } } + + # manage webhook service + if $pt_use_r10k_webhook == true { + require puppet_cd::r10k::install + + service { $pt_webhook_service: + ensure => running, + hasstatus => true, + hasrestart => true, + enable => true, + } + } } diff --git a/templates/r10k/hook_config.erb b/templates/r10k/hook_config.erb deleted file mode 100644 index 02237c3..0000000 --- a/templates/r10k/hook_config.erb +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "id": "r10k-deploy", - "execute-command": "/usr/local/bin/r10k-wrapper.sh", - "command-working-directory": "/etc/puppetlabs/code", - "pass-arguments-to-command": [ - { "source": "string", "name": "deploy" }, - { "source": "string", "name": "environment" }, - { "source": "string", "name": "-pv" } - ], - "trigger-rule": { - "and": [ - { - "match": { - "type": "value", - "value": "production", - "parameter": { - "source": "jsonpath", - "name": "$.object_attributes.target_branch" - } - } - }, - { - "match": { - "type": "value", - "value": "merge_request", - "parameter": { - "source": "jsonpath", - "name": "$.object_kind" - } - } - } - ] - } - } -] diff --git a/templates/r10k/r10k_webhook_service.erb b/templates/r10k/r10k_webhook_service.erb deleted file mode 100644 index 74bcffd..0000000 --- a/templates/r10k/r10k_webhook_service.erb +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Webhook Service for r10k Deployment -After=network.target - -[Service] -ExecStart=/usr/local/bin/webhook -hooks <%= @pt_r10k_hook_config_file %> -port 8088 -Restart=always -User=puppet -Group=puppet -WorkingDirectory=/etc/puppetlabs/code -StandardOutput=journal -StandardError=journal - -[Install] -WantedBy=multi-user.target