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

    P. Aiello

    12/03/2022, 10:50 AM
    “Much better signal to noise experience than Twitter IMHO.” this often depends on the amount of people active (and followed) though. When it is smaller, often is better
  • p

    P. Aiello

    12/03/2022, 3:02 PM
    Day 3 is there. https://adventofcode.com/2022/day/3 My solution added to the thread on the community repo: https://github.com/puppetlabs/community/discussions/28#discussioncomment-4298989 Today I had problems with understanding more some functions (the difficulty is in the details) and sometimes is not that easy to avoid reassigning variables, with that it would be much more simple (but less fun). Sharing solutions could help showing some less obvious functionality of puppet code. For example today I learned that string are iterable (I realized later that indeed they are indexed) and thus a whole lot could be done, but this info is not explicit in the documentation (at least I didn’t see it). @smortex I saw that you already solved things early, I hope you can add your solutions to the github thread (even a link is enough)!
  • p

    P. Aiello

    12/03/2022, 3:02 PM
    Day 3 is there. https://adventofcode.com/2022/day/3 My solution added to the thread on the community repo: https://github.com/puppetlabs/community/discussions/28#discussioncomment-4298989 Today I had problems with understanding more some functions (the difficulty is in the details) and sometimes is not that easy to avoid reassigning variables, with that it would be much more simple (but less fun). Sharing solutions could help showing some less obvious functionality of puppet code. For example today I learned that string are iterable (I realized later that indeed they are indexed) and thus a whole lot could be done, but this info is not explicit in the documentation (at least I didn’t see it). @smortex I saw that you already solved things early, I hope you can add your solutions to the github thread (even a link is enough)!
  • s

    Slackbot

    12/03/2022, 7:43 PM
    This message was deleted.
    b
    p
    h
    • 4
    • 6
  • s

    Slackbot

    12/04/2022, 2:14 AM
    This message was deleted.
    c
    p
    • 3
    • 5
  • y

    Yury Bushmelev

    12/04/2022, 4:35 AM
    This is what you’re looking for I guess: https://puppet.com/docs/puppet/7/lang_write_functions_in_puppet.html
  • y

    Yury Bushmelev

    12/04/2022, 4:36 AM
    And yes, $sum+=$value doesn’t work in Puppet.. I’d try with reduce() instead
  • s

    Slackbot

    12/05/2022, 3:55 AM
    This message was deleted.
    s
    d
    • 3
    • 2
  • s

    Slackbot

    12/05/2022, 5:36 AM
    This message was deleted.
    n
    c
    +3
    • 6
    • 13
  • y

    Yorokobi

    12/05/2022, 10:42 PM
    What is the proper way to ensure idempotency for a file resource that should not be created if an un-managed file exists on the node?
  • n

    natemccurdy

    12/05/2022, 10:58 PM
    With
    replace => false
    https://puppet.com/docs/puppet/7/types/file.html#file-attribute-replace
  • n

    natemccurdy

    12/05/2022, 10:59 PM
    But, note that this is just for the content of the file:
    Copy code
    Note that this only affects content; Puppet will still manage ownership and permissions.
  • y

    Yorokobi

    12/05/2022, 11:01 PM
    I want to manage a seed file's contents for a service's first run (yeah, this is orchestration, not CM) but I don't want to manage the resulting file when the service starts with the seed file (that will later be deleted by the service). To make this work the way I hope, I should manage the service-created file with
    replace => false
    setting only
    ensure => present
    as well?
  • n

    natemccurdy

    12/05/2022, 11:02 PM
    Will the service delete the seed file after it's used, or leave in in place but modified?
  • y

    Yorokobi

    12/05/2022, 11:02 PM
    Delete it.
  • n

    natemccurdy

    12/05/2022, 11:02 PM
    If the former, then Puppet will keep re-creating the file on each run after the service deletes the seed file.
  • n

    natemccurdy

    12/05/2022, 11:03 PM
    If the former, then Puppet will keep re-creating the file on each run after the service deletes the seed file.
  • y

    Yorokobi

    12/05/2022, 11:03 PM
    Hence my question 😄 It should only exist unless a file created by the service exists.
  • y

    Yorokobi

    12/05/2022, 11:04 PM
    I could probably get away with managing the service-created file so long as I only tweak one line but it'd require a restart of the service ... not ideal but not a deal breaker.
  • n

    natemccurdy

    12/05/2022, 11:06 PM
    What resources are we talking about here exactly? 1. The seed file:
    File[/etc/seed.txt]
    2. A service:
    Service[foo]
    3. Another file created by the service when it runs for the first time? And should the service always read the seed (1) and create the other file (3) when it starts? Or does that only happen as needed (i.e. when (3) doesn't exist)?
  • n

    natemccurdy

    12/05/2022, 11:06 PM
    What resources are we talking about here exactly? 1. The seed file:
    File[/etc/seed.txt]
    2. A service:
    Service[foo]
    3. Another file created by the service when it runs for the first time? And should the service always read the seed (1) and create the other file (3) when it starts? Or does that only happen as needed (i.e. when (3) doesn't exist)?
  • y

    Yorokobi

    12/05/2022, 11:09 PM
    Yes. Full disclosure, the service is Splunk (you can always presume that's what I'm playing with). When installed, one way to create the admin password is with a seed file ($SPLUNK_HOME/etc/system/local/user-seed.conf) that is read and deleted when Splunk is started. Splunk will then write the user name and hashed password to its etc/passwd file.
  • y

    Yorokobi

    12/05/2022, 11:10 PM
    Once Splunk is running I can have it hash any string as a password and replace it in the passwd file but it won't (I don't think ... I may have to test this) read the new password hash until restarted.
  • n

    natemccurdy

    12/05/2022, 11:10 PM
    Does its etc/passwd contain more than just that admin user's info?
  • y

    Yorokobi

    12/05/2022, 11:10 PM
    It can, yes.
  • n

    natemccurdy

    12/05/2022, 11:11 PM
    Got it. That complicates things for Puppet. And I presume it's not ideal to have the seed file laying around or existing when Splunk is running normally?
  • y

    Yorokobi

    12/05/2022, 11:12 PM
    Correct. I can encrypt the password in an eyaml file but it'd be sitting around in plain text on the node.
  • y

    Yorokobi

    12/05/2022, 11:12 PM
    This may be a good excuse for me to bump this over to a Bolt plan 🤔
  • n

    n3snah

    12/05/2022, 11:14 PM
    sounds very much like a plan/task would suit your requirements.
  • n

    natemccurdy

    12/05/2022, 11:15 PM
    So, to make this idempotent in Puppet (assuming you choose to do this with Puppet at all), you'd need some way to tell Puppet that the admin hash exists in Splunk's etc/passwd. The standard way to do that is a custom fact. Which you would write to check for the existence of a certain line or pattern in that file and return a boolean
    true
    or
    false.
    You could then wrap the seed file's
    file
    resource in an
    unless $facts['splunk_admin_hash_exists'] {
    conditional (using whatever fact name you created). But that's pretty fragile.... +1 to Bolt, or some other orchestration tool. Even just a wrapper script that handles it all so the files themselves aren't Puppet-managed would probably be better.
1...245246247...428Latest