https://www.puppet.com/community logo
Join Slack
Powered by
# puppet-enterprise
  • b

    bastelfreak

    05/01/2023, 5:08 PM
    I highly recommend setting as much as possible via hiera, and not via node groups
  • t

    todd.seidenberg

    05/01/2023, 5:08 PM
    Copy code
    $git_env = $::server_facts[environment]
     if (($git_env == 'development') or ($git_env == 'dev_puppet')) {
        $activation_key = 'centosdevkey'
      }
      elsif ($git_env == 'test') {
        $activation_key = 'centostestkey'
      }
      elsif ($git_env == 'acceptance') {
        $activation_key = 'centosacpkey'
      }
      elsif ($git_env == 'production') {
        $activation_key = 'centosprdkey'
      }
  • t

    todd.seidenberg

    05/01/2023, 5:09 PM
    So what I'm in the process of doing is removing the different
    server_facts[environment]
    settings, and switching to a single environment.
    👍 1
  • t

    todd.seidenberg

    05/01/2023, 5:09 PM
    But I need to still assign different
    $activation_keys
  • b

    bastelfreak

    05/01/2023, 5:10 PM
    if possible I would turn
    $activation_key
    into a class parameter and configure it in hiera
  • t

    todd.seidenberg

    05/01/2023, 5:10 PM
    so do that rather than determine the activiation key by the hostname? Because I can do that. I have a naming standard that allows me to determine that.
  • t

    todd.seidenberg

    05/01/2023, 5:11 PM
    But statically doing it with hiera is better?
  • b

    bastelfreak

    05/01/2023, 5:11 PM
    many ways lead to rome
  • b

    bastelfreak

    05/01/2023, 5:11 PM
    (if that makes sense in english)
  • t

    todd.seidenberg

    05/01/2023, 5:11 PM
    hahahha
  • b

    bastelfreak

    05/01/2023, 5:12 PM
    if you can set it via hostname, maybe put the logic in the class that uses the variable and don't use hiera at all
  • b

    bastelfreak

    05/01/2023, 5:12 PM
    then you're calculating the value, you don't set it statically
  • b

    bastelfreak

    05/01/2023, 5:13 PM
    I usually prefer such patterns because that makes it (sometimes) more future proof, but that always depends on the infrastructure
  • s

    spp

    05/01/2023, 5:13 PM
    If you don't want to use hiera, you can set the parameter in the console per node group. Hiera is infinitely better, though.
  • t

    todd.seidenberg

    05/01/2023, 5:13 PM
    ok
  • v

    vchepkov

    05/01/2023, 5:14 PM
    I am not sure if certname is a fact, but you can always make some for example, lets assume all your nodes format xxxYYY where YYY is tier
    Copy code
    Facter.add(:certname) do
      setcode do
        Puppet.settings[:certname]
      end
    end
    Facter.add(:tier) do
      setcode do
        certname = Facter.value(:certname)
        if certname =~ /^\w{3}(\w{3})/i
          $1
        else
          nil
        end
      end
    end
  • t

    todd.seidenberg

    05/01/2023, 5:15 PM
    Ah
  • t

    todd.seidenberg

    05/01/2023, 5:15 PM
    I understand
  • s

    Slackbot

    05/01/2023, 5:15 PM
    This message was deleted.
    👍 1
    v
    b
    • 3
    • 11
  • v

    vchepkov

    05/01/2023, 5:15 PM
    then in your hiera.yaml you would do
    Copy code
    paths:
          - "tiers/%{facts.tier}.yaml"
  • b

    bastelfreak

    05/01/2023, 5:16 PM
    of facts that are used to assign data/classes I highly recommend using trusted facts/server side facts instead. An agent can manipulate their own facts and potentially request code that's not meant for it
  • v

    vchepkov

    05/01/2023, 5:16 PM
    hence suggestion to use cert extension before
  • b

    bastelfreak

    05/01/2023, 5:16 PM
    if you don't have a
    tier
    entry in your certificate it's quite easy to update the csr_attributes and create a new cert
  • b

    bastelfreak

    05/01/2023, 5:17 PM
    https://github.com/voxpupuli/puppet-puppet_certificate
  • b

    bastelfreak

    05/01/2023, 5:17 PM
    we've a module for that!
  • t

    todd.seidenberg

    05/01/2023, 5:17 PM
    wait
    %{facts.tier}.yaml
    - that would interpolate a fact called
    tier
    ?
  • b

    bastelfreak

    05/01/2023, 5:17 PM
    yes
  • v

    vchepkov

    05/01/2023, 5:17 PM
    yep
  • b

    bastelfreak

    05/01/2023, 5:17 PM
    (keep in mind that this is hiera code/logic)
  • t

    todd.seidenberg

    05/01/2023, 5:17 PM
    Yes - i see that
1...495051...73Latest