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

    Slackbot

    12/01/2022, 7:24 PM
    This message was deleted.
    ❤️ 1
    p
    s
    +2
    • 5
    • 41
  • n

    natemccurdy

    12/01/2022, 7:32 PM
    There are two ways to get external data into a defined type in any reasonably consistent way, and with using built-in methods. Here's an example:
    Copy code
    define foo::bar (
      $some_param = lookup('foo::some_hiera_data'),
    ) {
    
      include foo::some_class
      notify { 'example':
        message => "A variable from another class: ${foo::some_class::hello}",
      }
    }
  • s

    smortex

    12/01/2022, 8:49 PM
    Haha, fun exercise 🙂 You can separate data and code with https://puppet.com/docs/puppet/7/function.html#file I find it helps to think about the data "globallly" to transform it: what
    file()
    return is a String, we can split it to have an Array[String] for each elf, then map that array to build an Array[Array[Integer]] for each elf carry, then reduce it into an Array[Integer] for the sum of each elf carry, and so on. This avoid the difficulty of thinking with counters which value change. Also, a bolt project (
    bolt apply
    ) or a simple manifest (
    puppet apply
    ) can probably help you to run the program more easily.
  • s

    smortex

    12/01/2022, 8:49 PM
    Haha, fun exercise 🙂 You can separate data and code with https://puppet.com/docs/puppet/7/function.html#file I find it helps to think about the data "globallly" to transform it: what
    file()
    return is a String, we can
    split
    it to have an Array[String] for each elf, then
    map
    that array to build an Array[Array[Integer]] for each elf carry, then
    reduce
    it into an Array[Integer] for the sum of each elf carry, and so on. This avoid the difficulty of thinking with counters which value change. Also, a bolt project (
    bolt apply
    ) or a simple manifest (
    puppet apply
    ) can probably help you to run the program more easily.
  • s

    smortex

    12/01/2022, 8:50 PM
    Haha, fun exercise 🙂 You can separate data and code with https://puppet.com/docs/puppet/7/function.html#file I find it helps to think about the data "globallly" to transform it: what
    file()
    return is a String, we can
    split()
    it to have an Array[String] for each elf, then
    map()
    that array to build an Array[Array[Integer]] for each elf carry, then
    reduce()
    it into an Array[Integer] for the sum of each elf carry, and so on. This avoid the difficulty of thinking with counters which value change. Also, a bolt project (
    bolt apply
    ) or a simple manifest (
    puppet apply
    ) can probably help you to run the program more easily.
  • s

    smortex

    12/01/2022, 8:51 PM
    Good exercise also for writting custom functions, I was surprised there is no
    sum()
    function 🙃
  • d

    Dr Bunsen Honeydew

    12/01/2022, 9:45 PM
    allthethings 🧑🏫PE Console is about to start up in #CFD8Z9A4T
  • s

    Steve Handy

    12/01/2022, 11:04 PM
    message has been deleted
  • s

    Slackbot

    12/01/2022, 11:16 PM
    This message was deleted.
    n
    s
    +2
    • 5
    • 36
  • l

    Lumiere

    12/01/2022, 11:20 PM
    so that's an anti-pattern to puppet, puppet is designed to take a state you want to get to, and take you there. so the idea of "only change something if you find it is installed" is not how puppet is designed to work, it's designed to have a "I want these installed"
    💯 7
  • l

    Lumiere

    12/01/2022, 11:20 PM
    I would look into hiera with lookup options to setup a list by role/location/os version
  • l

    Lumiere

    12/01/2022, 11:21 PM
    so you can pass the packages to the provider based on as specific a profile as possible
  • s

    Steve Handy

    12/02/2022, 12:19 AM
    Hi natemccurdy. How are you? Thanks for code. I am getting a small error: Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Method call, 'regsubst' parameter 'target' expects a value of type Array or String, got Struct (file: /etc/puppetlabs/code/environments/production/modules/testsoftware/manifests/init.pp, line: 4, column: 69)
  • n

    natemccurdy

    12/02/2022, 1:00 AM
    https://puppet.com/docs/puppet/7/style_guide.html#style_guide_classes-param-defaults https://puppet.com/docs/puppet/7/style_guide.html#style_guide_classes-type-signatures
    We recommend always using type signatures for class and defined type parameters.
  • p

    P. Aiello

    12/02/2022, 8:48 AM
    I don’t plan to use bolt (although for what I understood that is the way puppet becomes more procedural, a la Ansible)
  • s

    Slackbot

    12/02/2022, 10:59 AM
    This message was deleted.
    c
    s
    • 3
    • 3
  • s

    sh6624gsj8

    12/02/2022, 10:59 AM
    Hello , I have a puppet module similar to - https://github.com/puppetlabs/puppetlabs-java_ks , to manage my java keystore . where I have my definition as :-
    Copy code
    test_java_ks { "${module_name}:/etc/pki/test/truststore.p12":
      ensure       => present,
      certificate  => '/etc/pki/test/fqdn_cert.crt',
      password     => 'somepass',
      storetype    => 'pkcs12',
      trustcacerts => 'true',
    }
    I am only trying to change my ensure from
    present
    to
    latest
    - However , I am not sure why do I get ensure changed 'present' to 'latest' on a the file when it is already the latest. I understand that it triggers in the first run , but not sure why I get it on each execution . Some logs from debug mode :-
    Copy code
    Debug: /Stage[main]/Java/Anchor[java::begin:]/before: before to Package[java]
    Debug: /Stage[main]/Java/Package[java]/before: before to Class[Java::Config]
    Debug: /Stage[main]/Java::Config/before: before to Anchor[java::end]
    Debug: /Stage[main]/Main/File[/etc/pki/test/truststore.p12]/require: require to Test_java_ks[fqdn_cert:/etc/pki/test/truststore.p12]
    Debug: /Stage[main]/Main/File[/etc/pki/test/truststore.p12]/before: before to File[/etc/pki/test/keystore.p12]
    Debug: /Stage[main]/Main/File[/etc/pki/test/keystore.p12]/require: require to Test_java_ks[fqdn_cert:/etc/pki/test/keystore.p12]
    Debug: /Stage[main]/Main/Test_java_ks[:/etc/pki/test/truststore.p12]/before: before to Test_java_ks[fqdn_cert:/etc/pki/test/truststore.p12]
    Debug: /Stage[main]/Main/Test_java_ks[:/etc/pki/test/keystore.p12]/before: before to Test_java_ks[fqdn_cert:/etc/pki/test/keystore.p12]
    Debug: Prefetching yum resources for package
    Debug: Executing: '/usr/bin/rpm --version'
    Debug: Executing '/usr/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n' | sort'
    Debug: Executing: 'keytool -list -keystore /etc/pki/test/truststore.p12 -alias  -storetype pkcs12'
    Debug: Executing: 'keytool -v -printcert -file /etc/pki/test/fqdn_cert.crt -storetype pkcs12'
    Debug: Executing: 'keytool -list -v -keystore /etc/pki/test/truststore.p12 -alias  -storetype pkcs12'
    Debug: Executing: 'keytool -list -keystore /etc/pki/test/truststore.p12 -alias  -storetype pkcs12'
    Debug: Executing: 'keytool -delete -alias  -keystore /etc/pki/test/truststore.p12'
    Debug: Executing: 'keytool -importcert -noprompt -alias  -file /etc/pki/test/fqdn_cert.crt -keystore /etc/pki/test/truststore.p12 -storetype pkcs12 -trustcacerts'
    Notice: /Stage[main]/Main/Ahub_java_ks[:/etc/pki/shared_service/truststore.p12]/ensure: ensure changed 'present' to 'latest'
  • s

    sh6624gsj8

    12/02/2022, 11:00 AM
    Hello , I have a puppet module similar to - https://github.com/puppetlabs/puppetlabs-java_ks , to manage my java keystore . where I have my definition as :-
    Copy code
    test_java_ks { "${module_name}:/etc/pki/test/truststore.p12":
      ensure       => present,
      certificate  => '/etc/pki/test/fqdn_cert.crt',
      password     => 'somepass',
      storetype    => 'pkcs12',
      trustcacerts => 'true',
    }
    I am only trying to change my ensure from
    present
    to
    latest
    - However , I am not sure why do I get ensure changed 'present' to 'latest' on a the file when it is already the latest. I understand that it triggers in the first run , but not sure why I get it on each execution . Some logs from debug mode :-
    Copy code
    Debug: /Stage[main]/Java/Anchor[java::begin:]/before: before to Package[java]
    Debug: /Stage[main]/Java/Package[java]/before: before to Class[Java::Config]
    Debug: /Stage[main]/Java::Config/before: before to Anchor[java::end]
    Debug: /Stage[main]/Main/File[/etc/pki/test/truststore.p12]/require: require to Test_java_ks[fqdn_cert:/etc/pki/test/truststore.p12]
    Debug: /Stage[main]/Main/File[/etc/pki/test/truststore.p12]/before: before to File[/etc/pki/test/keystore.p12]
    Debug: /Stage[main]/Main/File[/etc/pki/test/keystore.p12]/require: require to Test_java_ks[fqdn_cert:/etc/pki/test/keystore.p12]
    Debug: /Stage[main]/Main/Test_java_ks[:/etc/pki/test/truststore.p12]/before: before to Test_java_ks[fqdn_cert:/etc/pki/test/truststore.p12]
    Debug: /Stage[main]/Main/Test_java_ks[:/etc/pki/test/keystore.p12]/before: before to Test_java_ks[fqdn_cert:/etc/pki/test/keystore.p12]
    Debug: Prefetching yum resources for package
    Debug: Executing: '/usr/bin/rpm --version'
    Debug: Executing '/usr/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n' | sort'
    Debug: Executing: 'keytool -list -keystore /etc/pki/test/truststore.p12 -alias  -storetype pkcs12'
    Debug: Executing: 'keytool -v -printcert -file /etc/pki/test/fqdn_cert.crt -storetype pkcs12'
    Debug: Executing: 'keytool -list -v -keystore /etc/pki/test/truststore.p12 -alias  -storetype pkcs12'
    Debug: Executing: 'keytool -list -keystore /etc/pki/test/truststore.p12 -alias  -storetype pkcs12'
    Debug: Executing: 'keytool -delete -alias  -keystore /etc/pki/test/truststore.p12'
    Debug: Executing: 'keytool -importcert -noprompt -alias  -file /etc/pki/test/fqdn_cert.crt -keystore /etc/pki/test/truststore.p12 -storetype pkcs12 -trustcacerts'
    Notice: /Stage[main]/Main/Ahub_java_ks[:/etc/pki/shared_service/truststore.p12]/ensure: ensure changed 'present' to 'latest'
    Could you someone please help me clarify this ?
  • s

    sh6624gsj8

    12/02/2022, 11:00 AM
    Hello , I have a puppet module similar to - https://github.com/puppetlabs/puppetlabs-java_ks , to manage my java keystore . where I have my definition as :-
    Copy code
    test_java_ks { "${module_name}:/etc/pki/test/truststore.p12":
      ensure       => present,
      certificate  => '/etc/pki/test/fqdn_cert.crt',
      password     => 'somepass',
      storetype    => 'pkcs12',
      trustcacerts => 'true',
    }
    I am only trying to change my ensure from
    present
    to
    latest
    - However , I am not sure why do I get ensure changed '`present`' to '`latest`' on a the file when it is already the latest. I understand that it triggers in the first run , but not sure why I get it on each execution . Some logs from debug mode :-
    Copy code
    Debug: /Stage[main]/Java/Anchor[java::begin:]/before: before to Package[java]
    Debug: /Stage[main]/Java/Package[java]/before: before to Class[Java::Config]
    Debug: /Stage[main]/Java::Config/before: before to Anchor[java::end]
    Debug: /Stage[main]/Main/File[/etc/pki/test/truststore.p12]/require: require to Test_java_ks[fqdn_cert:/etc/pki/test/truststore.p12]
    Debug: /Stage[main]/Main/File[/etc/pki/test/truststore.p12]/before: before to File[/etc/pki/test/keystore.p12]
    Debug: /Stage[main]/Main/File[/etc/pki/test/keystore.p12]/require: require to Test_java_ks[fqdn_cert:/etc/pki/test/keystore.p12]
    Debug: /Stage[main]/Main/Test_java_ks[:/etc/pki/test/truststore.p12]/before: before to Test_java_ks[fqdn_cert:/etc/pki/test/truststore.p12]
    Debug: /Stage[main]/Main/Test_java_ks[:/etc/pki/test/keystore.p12]/before: before to Test_java_ks[fqdn_cert:/etc/pki/test/keystore.p12]
    Debug: Prefetching yum resources for package
    Debug: Executing: '/usr/bin/rpm --version'
    Debug: Executing '/usr/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n' | sort'
    Debug: Executing: 'keytool -list -keystore /etc/pki/test/truststore.p12 -alias  -storetype pkcs12'
    Debug: Executing: 'keytool -v -printcert -file /etc/pki/test/fqdn_cert.crt -storetype pkcs12'
    Debug: Executing: 'keytool -list -v -keystore /etc/pki/test/truststore.p12 -alias  -storetype pkcs12'
    Debug: Executing: 'keytool -list -keystore /etc/pki/test/truststore.p12 -alias  -storetype pkcs12'
    Debug: Executing: 'keytool -delete -alias  -keystore /etc/pki/test/truststore.p12'
    Debug: Executing: 'keytool -importcert -noprompt -alias  -file /etc/pki/test/fqdn_cert.crt -keystore /etc/pki/test/truststore.p12 -storetype pkcs12 -trustcacerts'
    Notice: /Stage[main]/Main/Ahub_java_ks[:/etc/pki/shared_service/truststore.p12]/ensure: ensure changed 'present' to 'latest'
    Could you someone please help me clarify this ?
  • s

    Slackbot

    12/02/2022, 2:28 PM
    This message was deleted.
    b
    n
    • 3
    • 2
  • y

    Yury Bushmelev

    12/02/2022, 3:03 PM
    I got 502 from puppet forge just now 🤔
  • p

    P. Aiello

    12/02/2022, 3:46 PM
    https://adventofcode.com/2022/day/2 Day 2 is out, and I tried to at least improve on the file readability. Let’s see if others have nice nuggets to steal learn from. My code https://osdn.net/users/pier4r/pastebin/9134
  • s

    Slackbot

    12/02/2022, 5:00 PM
    This message was deleted.
    b
    • 2
    • 2
  • s

    smortex

    12/02/2022, 5:51 PM
    Here is mine: https://gist.github.com/smortex/42f79bc7db8d0344338affd5027e1276
  • s

    Slackbot

    12/02/2022, 6:49 PM
    This message was deleted.
    b
    n
    +5
    • 8
    • 14
  • s

    Slackbot

    12/02/2022, 7:59 PM
    This message was deleted.
    n
    l
    • 3
    • 8
  • n

    nmaludy

    12/02/2022, 8:02 PM
    run that on any Puppet Server
  • n

    nmaludy

    12/02/2022, 8:02 PM
    you're welcome, enjoy!
  • p

    P. Aiello

    12/02/2022, 8:58 PM
    and here it is https://github.com/puppetlabs/community/discussions/28
  • n

    nmaludy

    12/03/2022, 4:30 AM
    need a Puppet module for Mastodon 🙂
1...244245246...428Latest