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

    sheikh

    02/01/2023, 5:14 PM
    Hello out there simple question, new to puppet world! I would like to verify lines, if not present add lines at the end in the config file. I have to check following lines in the location : /etc/screenrc
    Copy code
    bindkey "^D" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'
    bind "^M" quit
    How to adopt in below manifest file or any different way? Thanks
    Copy code
    file {'/etc/screenrc':
        ensure => 'file',
      }
      file_line {'':
        path    => '/etc/screenrc',
        line    => '',
        require => File['/etc/screenrc'],
      }
  • c

    Corporate Gadfly

    02/01/2023, 6:02 PM
    Yes, you are likely correct about globs. In my
    facter -p
    output, I still see the following, even though I have
    memory.swap.used*
    in the blocklist:
    Copy code
    memory => {
      swap => {
        available_bytes => 3883233280,
        total => "4.00 GiB",
        total_bytes => 4294963200,
        used_bytes => 411729920
      },
      system => {
        available_bytes => 1616789504,
        total => "11.43 GiB",
        total_bytes => 12273041408,
        used_bytes => 10656251904
      }
    }
  • c

    Corporate Gadfly

    02/01/2023, 6:06 PM
    That's right. I changed the globs to individual items:
    Copy code
    "memory.swap.used"
    "memory.swap.used_bytes"
    And the output from
    facter -p
    changed to:
    Copy code
    memory => {
      swap => {
        available => "3.62 GiB",
        total => "4.00 GiB",
        total_bytes => 4294963200
      },
      system => {
        available => "1.51 GiB",
        total => "11.43 GiB",
        total_bytes => 12273041408
      }
    }
  • c

    Corporate Gadfly

    02/01/2023, 6:07 PM
    That's right. I replaced the globs with individual items:
    Copy code
    "memory.swap.used"
    "memory.swap.used_bytes"
    And the output from
    facter -p
    changed to:
    Copy code
    memory => {
      swap => {
        available => "3.62 GiB",
        total => "4.00 GiB",
        total_bytes => 4294963200
      },
      system => {
        available => "1.51 GiB",
        total => "11.43 GiB",
        total_bytes => 12273041408
      }
    }
  • c

    Corporate Gadfly

    02/01/2023, 6:07 PM
    That's right. I replaced the globs with individual items:
    Copy code
    "memory.swap.used"
    "memory.swap.used_bytes"
    and the output from
    facter -p
    changed to:
    Copy code
    memory => {
      swap => {
        available => "3.62 GiB",
        total => "4.00 GiB",
        total_bytes => 4294963200
      },
      system => {
        available => "1.51 GiB",
        total => "11.43 GiB",
        total_bytes => 12273041408
      }
    }
  • c

    Corporate Gadfly

    02/01/2023, 6:08 PM
    That's right. I replaced the globs with individual items:
    Copy code
    "memory.system.used",
    "memory.system.used_bytes",
    "memory.swap.used",
    "memory.swap.used_bytes",
    and the output from
    facter -p
    changed to:
    Copy code
    memory => {
      swap => {
        available => "3.62 GiB",
        total => "4.00 GiB",
        total_bytes => 4294963200
      },
      system => {
        available => "1.51 GiB",
        total => "11.43 GiB",
        total_bytes => 12273041408
      }
    }
  • c

    Corporate Gadfly

    02/01/2023, 6:11 PM
    @Sergei G.: Since puppet is not a monitoring system and I don't care about ephemeral facts, I have the following in
    /etc/puppetlabs/facter/facter.conf
    to block unwanted facts:
    Copy code
    facts : {
      blocklist : [
        "file system",
        "load_averages",
        "identity",
        "memory.system.capacity",
        "memory.system.used",
        "memory.system.used_bytes",
        "memory.system.available",
        "memory.system.available_bytes",
        "memory.swap.capacity",
        "memory.swap.used",
        "memory.swap.used_bytes",
        "memory.swap.available",
        "memory.swap.available_bytes",
        "system_uptime",
      ]
    }
    Hope that helps.
  • c

    Corporate Gadfly

    02/01/2023, 6:16 PM
    That's right. I replaced the globs with individual items:
    Copy code
    "memory.system.used",
    "memory.system.used_bytes",
    "memory.swap.used",
    "memory.swap.used_bytes",
    and the output from
    facter -p
    changed to:
    Copy code
    memory => {
      swap => {
        available => "3.62 GiB",
        total => "4.00 GiB",
        total_bytes => 4294963200
      },
      system => {
        available => "1.51 GiB",
        total => "11.43 GiB",
        total_bytes => 12273041408
      }
    }
    and you can see
    used
    and
    used_bytes
    is no longer there.
  • n

    natemccurdy

    02/01/2023, 6:18 PM
    Thanks. That looks good. So I suspect the problem then is that the code you've written there isn't the code that's being applied. Can you show a couple of the lines below that red error message in the screenshot you posted earlier? That'll tell me where in the Puppet code the offending resource is coming from.
  • n

    natemccurdy

    02/01/2023, 6:20 PM
    Also, on that node that's failing its Puppet run, please run this as root and show me the result:
    Copy code
    facter os
  • j

    jballiet

    02/01/2023, 7:16 PM
    message has been deleted
  • v

    vchepkov

    02/01/2023, 8:50 PM
    stepped on something new in puppet7, another warning
    Copy code
    warning:[Puppet]: Fact value '#!/bin/bash
    ...
    with the value length: '4772' exceeds the value length limit: 4096
    I think fact name instead of the whole value printed in log would be more useful. especially since that fact can have a sensitive data
  • v

    vchepkov

    02/01/2023, 8:51 PM
    in this case ec2_userdata is a culprit
  • s

    sheikh

    02/01/2023, 8:52 PM
    Hello out there simple question, new to puppet world! I would like to verify lines, if not present add lines at the end in the config file. I have to check following lines in the location : /etc/screenrc
    Copy code
    bindkey "^D" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'
    bind "^M" quit
    How to adopt in below manifest file or any different way? Thanks
    Copy code
    file { '/etc/screenrc':
      ensure  => file,
      content => "hello\nworld\n",
    }
  • s

    sheikh

    02/01/2023, 9:23 PM
    message has been deleted
  • s

    sheikh

    02/01/2023, 9:23 PM
    message has been deleted
  • s

    sheikh

    02/01/2023, 9:33 PM
    Hello out there simple question, new to puppet world! I would like to verify lines, if not present add lines at the end in the config file. I have to check following lines in the location : /etc/screenrc
    Copy code
    defscrollback 30000
    bindkey "^C" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'
    bindkey "^D" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'
    bind "^M" quit
    How to adopt in below manifest file or any different way? Thanks
    Copy code
    file { '/etc/screenrc':
      ensure => file,
      append => "defscrollback 30000\nbindkey \"^C\" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'\nbindkey \"^D\" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'\nbind \"^M\" quit\n",
    }
  • s

    sheikh

    02/01/2023, 10:22 PM
    This message was deleted.
  • s

    Slackbot

    02/01/2023, 10:24 PM
    This message was deleted.
    r
    d
    • 3
    • 2
  • s

    sheikh

    02/01/2023, 10:27 PM
    hello out there, Below manifest added content in the file at end.
    Copy code
    $contents = file('/etc/screenrc')
    
    $new_contents = "${contents}defscrollback 30000\nbindkey \"^C\" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'\nbindkey \"^D\" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'\nbind \"^M\" quit\n"
    
    file { '/etc/screenrc':
      content  => $new_contents,
      ensure => file,
    }
    Output:
    Copy code
    # #shelltitle ' |zsh'
    # #shelltitle '> |csh'
    # #shelltitle '$ |bash'
    defscrollback 30000
    bindkey "^C" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'
    bindkey "^D" echo 'Blocked. Please use [Ctrl]+[A] + [Ctrl]+[Enter] + [Y]'
    bind "^M" quit
    But when running manifest file again, then content added two times, how to prevent this or something to verify if same content there not add it again. thanks
  • s

    Slackbot

    02/01/2023, 11:18 PM
    This message was deleted.
    c
    r
    r
    • 4
    • 3
  • c

    Corporate Gadfly

    02/02/2023, 1:04 AM
    That's right. I replaced the globs with individual items:
    Copy code
    "memory.system.used",
    "memory.system.used_bytes",
    "memory.swap.used",
    "memory.swap.used_bytes",
    and the output from
    facter -p
    changed to:
    Copy code
    memory => {
      swap => {
        available => "3.62 GiB",
        total => "4.00 GiB",
        total_bytes => 4294963200
      },
      system => {
        available => "1.51 GiB",
        total => "11.43 GiB",
        total_bytes => 12273041408
      }
    }
    and you can see
    used
    and
    used_bytes
    are no longer there.
  • s

    sheikh

    02/02/2023, 7:25 AM
    This message was deleted.
  • c

    canihavethisone

    02/02/2023, 9:17 AM
    @helindbe thanks for your suggestions above, I ended up using the Enum as below as i could not get the
    any
    to work:
    Copy code
    unless (Enum[$k] in $valid_sections) {
            fail("Invalid section '${k}' in '${key}' hash. Verify the section is valid and in correct CaSe")
          }
  • p

    pig

    02/02/2023, 9:45 AM
    Hello, I'm trying to to set a sensitive value in an epp following https://www.puppet.com/docs/puppet/7/lang_template_epp.html#epp_variables-epp-sensitive-data and I am not able to do it. Basically every time I try to use
    scope
    in the template I get the following error (it doesn't matter if it has
    ::sensitive
    or not, I always get the same error):
    Copy code
    Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: A substring operation does not accept a String as a character index. Expected an Integer
    It doesn't matter if I pass the variables as parameters of the
    epp
    function in the manifest, or if I use the name with the full scope of the variable, I get also the same error). The only way I can make it work is with the
    $::module::variable
    syntax (or
    $variable
    if I pass it as a parameter) but then I can't mark the value as sensitive in the epp template. Anyone can give me a hand with this please šŸ™‚ ? (I'm using Puppet 7 too)
  • s

    Slackbot

    02/02/2023, 9:54 AM
    This message was deleted.
    šŸ‘ 1
    d
    p
    • 3
    • 3
  • d

    David Sandilands

    02/02/2023, 9:56 AM
    Hey I'll raise a doc ticket to correct this, I would make the variable sensitive in the Puppet manifest and just pass it in like any other parameter since as of 6.20 EPP will unwrap sensitive values automatically. Scope was an ERB thing and shouldn't need to be used in EPP
  • s

    Slackbot

    02/02/2023, 12:39 PM
    This message was deleted.
    h
    r
    • 3
    • 2
  • s

    Slackbot

    02/02/2023, 1:16 PM
    This message was deleted.
    r
    b
    +2
    • 5
    • 18
  • b

    bastelfreak

    02/02/2023, 1:28 PM
    Copy code
    file { '/etc/screenrc':
      content => file("${module_name}/configs/screenrc"),
    }
    and put the file at files/configs/screenrc in your module
1...293294295...428Latest