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

    Andy Fry

    01/18/2023, 3:58 AM
    Yeah... but my head hurts now 😫
  • n

    n3snah

    01/18/2023, 3:59 AM
    you want the exit to be 0 if the host is already in your inventory
  • n

    n3snah

    01/18/2023, 4:01 AM
    unless would be what I would recommend here
  • a

    Andy Fry

    01/18/2023, 4:01 AM
    Unless always runs, onlyif never runs
  • n

    n3snah

    01/18/2023, 4:02 AM
    this would need extra testing but I think this might work
    Copy code
    exec { 'add_to_inventory':
      command => 'curl blah',
      unless  => 'curl (host url from awx) 2>/dev/null | grep -c $hostname || exit 0'
    }
  • a

    Andy Fry

    01/18/2023, 4:02 AM
    That's bash exit code, not stdout value right
  • n

    n3snah

    01/18/2023, 4:02 AM
    this would need extra testing but I think this might work
    Copy code
    exec { 'add_to_inventory':
      command => 'curl blah',
      unless  => 'curl (host url from awx) 2>/dev/null | grep -c $hostname || exit 0'
    }
  • n

    n3snah

    01/18/2023, 4:03 AM
    yes correct.. its the return code of the unless
  • n

    n3snah

    01/18/2023, 4:03 AM
    yes correct.. its the return code of the unless
  • n

    n3snah

    01/18/2023, 4:04 AM
    it may be useful to have a dedicated script in your
    unless
    to handle the logic better
  • a

    Andy Fry

    01/18/2023, 4:09 AM
    I think I may have to do that. Was hoping to avoid it but the logic may be too complex
  • a

    Andy Fry

    01/18/2023, 4:09 AM
    This failed I'm afraid. Unless didn't run and onlyif runs every time now lol.
  • y

    Yury Bushmelev

    01/18/2023, 4:14 AM
    curl return codes are.. a bit special.. there is an option that simplifies things but I don’t remember it :) I hit into return code issue while ago and found some unexpected behaviour which is explained in man page though
  • n

    n3snah

    01/18/2023, 4:19 AM
    but was that machine in your inventory already @Andy Fry?
  • n

    n3snah

    01/18/2023, 4:19 AM
    exec shouldn't run if it was in the inventory
  • s

    Slackbot

    01/18/2023, 5:30 AM
    This message was deleted.
    a
    • 2
    • 1
  • y

    Yury Bushmelev

    01/18/2023, 7:18 AM
    Ah, good catch!
  • s

    Slackbot

    01/18/2023, 7:27 AM
    This message was deleted.
    y
    g
    • 3
    • 4
  • s

    Slackbot

    01/18/2023, 7:48 AM
    This message was deleted.
    y
    • 2
    • 1
  • y

    Yury Bushmelev

    01/18/2023, 8:37 AM
    you should be able to do it once on a Linux server šŸ™‚
  • g

    Ganaparthi Nikhil

    01/18/2023, 12:05 PM
    hi team any solution for above error
  • g

    Ganaparthi Nikhil

    01/18/2023, 12:06 PM
    message has been deleted
  • g

    Ganaparthi Nikhil

    01/18/2023, 12:06 PM
    Error: Could not request certificate: SSL_connect returned=1 errno=0 state=error: certificate verify failed: [certificate is not yet valid for /CN=Puppet CA generated on us.********.com Exiting; failed to retrieve certificate and waitforcert is disabled
  • m

    Marty Ewings

    01/18/2023, 12:39 PM
    ā€œcertificate is not yet valid forā€
  • m

    Marty Ewings

    01/18/2023, 12:39 PM
    this implies that the certs start date is in the future relative to to the time on the CA server
  • m

    Marty Ewings

    01/18/2023, 12:40 PM
    so either the cert was generated intentionally in the future, on a machine whos clock is wrong, or the CA servers clock is wrong
  • g

    Ganaparthi Nikhil

    01/18/2023, 12:44 PM
    is there any solution to resolve
  • b

    bastelfreak

    01/18/2023, 12:59 PM
    checking if NTP is configured is a good first step
    šŸ’Æ 1
  • g

    Ganaparthi Nikhil

    01/18/2023, 1:06 PM
    is there any chance to change the clock in ssl crtificates
  • g

    Ganaparthi Nikhil

    01/18/2023, 1:07 PM
    how to check the NTP issue
1...276277278...428Latest