https://www.puppet.com/community logo
Join Slack
Powered by
# puppet
  • s

    Slackbot

    05/06/2022, 9:44 AM
    This message was deleted.
    m
    • 2
    • 1
  • s

    Sam

    05/06/2022, 10:17 AM
    You are right here There is a common thing between these 3 servers i.e. hostname (fqdn) itself tcp-pub-app1-bla.bbb-qc.aws.aaa.com tcp-pub-app2-bla.bbb-qc.aws.aaa.com tcp-pub-app3-bla.bbb-qc.aws.aaa.com as of now, I have ignored etcsshsshd CIS on these 3 node definition in controlrepo hiera and manually applied rules required, so that puppet is not updating sshd_config file on these 3 nodes
    Copy code
    ---
    
    cem_linux::config:
      ignore:
        - ensure_permissions_on_etcsshsshd_config_are_configured
  • a

    Allahshukur Ahmadzada

    05/06/2022, 10:47 AM
    would not it be good if service resource type support unless/onlyif parameters? I need to check configuration before restarting service and for this I use seperate exec resource and require it on service, this works but causes to have corrective status all the time.
  • b

    bastelfreak

    05/06/2022, 10:48 AM
    you can update your systemd file so the service does a validation before the actual start
  • a

    Allahshukur Ahmadzada

    05/06/2022, 10:55 AM
    I know it looks ugly but what do you think using unless parameter in exec and copying command there too, it works but kinda funny
  • a

    Allahshukur Ahmadzada

    05/06/2022, 10:55 AM
    exec { 'check_auth':
    command => 'pdns_server --config=check',
    path    => ['/usr/bin', '/usr/sbin/', '/usr/local/sbin'],
    unless  => 'pdns_server --config=check'
    }
  • a

    Allahshukur Ahmadzada

    05/06/2022, 10:56 AM
    lets use thread
  • m

    Massimiliano (Max)

    05/06/2022, 10:57 AM
    @Allahshukur Ahmadzada this is builtin with the module.... for instance haproxy module runs a check before trying to restart.
  • m

    Massimiliano (Max)

    05/06/2022, 10:57 AM
    PDNS ... lemme check.... I have it as well
  • a

    Allahshukur Ahmadzada

    05/06/2022, 10:57 AM
    I am building module myself
  • a

    Allahshukur Ahmadzada

    05/06/2022, 10:59 AM
    above exec works fine, do you see any problem having such exec and requiring it on service?
  • b

    bastelfreak

    05/06/2022, 10:59 AM
    yes. it's not idempotent
  • a

    Allahshukur Ahmadzada

    05/06/2022, 11:00 AM
    if sevice resource had unless/onlyif would it be idempotent?
  • b

    bastelfreak

    05/06/2022, 11:01 AM
    this is not really how puppet is designed to work
  • b

    bastelfreak

    05/06/2022, 11:01 AM
    what's the goal you aim for? To not restart a service if the config file is bad?
  • a

    Allahshukur Ahmadzada

    05/06/2022, 11:01 AM
    yes
  • b

    bastelfreak

    05/06/2022, 11:02 AM
    use a systemd dropin to add
    ExecStartPre=/usr/bin/pdns_server --config=check
    to the unit
  • m

    Massimiliano (Max)

    05/06/2022, 11:02 AM
    anyway, the powerDNS module that I am using is not checking the configuration. I have put a bogus parameter and it broke the service
  • b

    bastelfreak

    05/06/2022, 11:03 AM
    is the goal to validate the config before writing it? use https://puppet.com/docs/puppet/7/types/file.html#file-attribute-validate_cmd
    👍 1
  • b

    bastelfreak

    05/06/2022, 11:04 AM
    and is there a reason for writing your own module and not using the existing one?
    ☝️ 1
  • a

    Allahshukur Ahmadzada

    05/06/2022, 11:04 AM
    what if configuration is nested, like there 3 different config files, and check config checks all at once
  • a

    Allahshukur Ahmadzada

    05/06/2022, 11:05 AM
    so one file resource may fail because of another config file?
  • m

    Massimiliano (Max)

    05/06/2022, 11:05 AM
    anyhow.... the bogus parameter is not recognized by:
    pdns_recursor --config=check
  • m

    Massimiliano (Max)

    05/06/2022, 11:05 AM
    but service restart fails
  • a

    Allahshukur Ahmadzada

    05/06/2022, 11:05 AM
    I do not really understand why you are againist to have unless/onlfif in service
  • a

    Allahshukur Ahmadzada

    05/06/2022, 11:06 AM
    recursor has no check feature
  • m

    Massimiliano (Max)

    05/06/2022, 11:06 AM
    I have both. Let me try the other
  • a

    Allahshukur Ahmadzada

    05/06/2022, 11:07 AM
    exec { 'check_auth':
    command => 'pdns_server --config=check',
    path    => ['/usr/bin', '/usr/sbin/', '/usr/local/sbin'],
    unless  => 'pdns_server --config=check'
    }
    service { $service:
    ensure   => running,
    enable   => true,
    provider => systemd,
    require  => [ Exec['check_auth'], Package[$powerdns::authoritative_package]]
    }
  • a

    Allahshukur Ahmadzada

    05/06/2022, 11:07 AM
    this works, but it is like hack
  • m

    Massimiliano (Max)

    05/06/2022, 11:08 AM
    you're right. With authoritative server it works.
1...242526...428Latest