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

    riccsnet

    08/16/2022, 8:19 PM
    I am trying to remove a user from a group. The user get added to the group if an object in hieradata is not null. I would like to trigger user removal from the group if the hieradata is null. Another done anything like this? The addition code look like
    $css_users = hiera('css_users', {})
    $css_groups = ['wheel']
    }
    keys($css_users).each |$this_user| {
    if !empty($css_users[$this_user][yubikey]) {
    #notify { "${this_user} made it in the if defined block": }
    $css_groups = ['wheel', 'yubikeyusers']
    }
    #notify {"value of css_groups ${this_user}: ${css_groups}": }
    @user { $this_user:
    ensure           => present,
    password         => "${css_users[$this_user][password]}",
    comment          => "${css_users[$this_user][comment]}",
    managehome       => true,
    groups           => $css_groups,
    shell            => '/bin/bash',
    password_max_age => '-1',
    }
    }
    keys($css_users).each |$this_user| {
    User <|title == $this_user |>
    }
    }
  • r

    riccsnet

    08/16/2022, 8:20 PM
    I am trying to remove a user from a group. The user get added to the group if an object in hieradata is not null. I would like to trigger user removal from the group if the hieradata is null. Another done anything like this? The addition code look like
    $css_users = hiera('css_users', {})
    $css_groups = ['wheel']
    }
    keys($css_users).each |$this_user| {
    if !empty($css_users[$this_user][yubikey]) {
    #notify { "${this_user} made it in the if defined block": }
    $css_groups = ['wheel', 'yubikeyusers']
    }
    #notify {"value of css_groups ${this_user}: ${css_groups}": }
    @user { $this_user:
    ensure           => present,
    password         => "${css_users[$this_user][password]}",
    comment          => "${css_users[$this_user][comment]}",
    managehome       => true,
    groups           => $css_groups,
    shell            => '/bin/bash',
    password_max_age => '-1',
    }
    }
    keys($css_users).each |$this_user| {
    User <|title == $this_user |>
    }
    }
  • b

    binford2k

    08/16/2022, 9:16 PM
    I don’t completely grok what you’re solving for here, but a real good way to think about configuration management is to stop thinking in terms of actions and start thinking in terms of state. In other words, do not write code to add or remove the group, instead figure out how to generate a consistent list of the groups you expect the user to be a member of and then let Puppet figure out what to add or remove.
    ☝️ 2
    💯 1
    this2 1
    ➕ 1
    ☝🏼 1
  • s

    Slackbot

    08/16/2022, 10:55 PM
    This message was deleted.
    c
    l
    • 3
    • 3
  • a

    Anirudh Ramesh

    08/17/2022, 12:26 AM
    Can anybody tell if https://github.com/attachmentgenie/attachmentgenie-grafana_agent is an actively maintained repo? Puppet doc: https://forge.puppet.com/modules/attachmentgenie/grafana_agent There isn't much reference on usage either.
  • a

    Anirudh Ramesh

    08/17/2022, 12:26 AM
    Can anybody tell if https://github.com/attachmentgenie/attachmentgenie-grafana_agent is an actively maintained repo? Puppet doc: https://forge.puppet.com/modules/attachmentgenie/grafana_agent There isn't much reference on usage either.
  • d

    dimitry

    08/17/2022, 2:44 AM
    Hi there, hope you are doing well
  • d

    dimitry

    08/17/2022, 2:48 AM
    Copy code
    Puppet Evaluation Error: Error while evaluating a Function Call, Class[Profile::Cvmfs::Client]: expects a value for parameter 'my_variable' (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 19, column: 5) on node login1
  • d

    dimitry

    08/17/2022, 2:49 AM
    Question: I created a class to create a default user see below:
    Copy code
    class profile::some_user(
    String $my_variable= 'some_string'
    )
    {
      user { $my_variable:
        ensure     => present,
        forcelocal => true,
        gid        => 'some_gid',
        groups     => 'some_group',
        home       => "/${my_variable}",
        managehome => true,
        notify     => Selinux::Exec_restorecon["/${my_variable}"],
        uid        => 'some_uid',
      }
    }
    ) and then used the function
    ensure_resources(my_user_class, $my_variable)
    within another class in the same module
  • d

    dimitry

    08/17/2022, 2:54 AM
    I created a class to create a default user see bellow:
    Copy code
    class profile::some_user(
    String $my_variable= 'some_string'
    )
    {
      user { $my_variable:
        ensure     => present,
        forcelocal => true,
        gid        => 'some_gid',
        groups     => 'some_group',
        home       => "/${$my_variable}",
        managehome => true,
        notify     => Selinux::Exec_restorecon["/${$my_variable}"],
        uid        => 'some_uid',
      }
    }
    ) and then used the function `ensure_resources(my_user_class, $my_variable)
  • d

    dimitry

    08/17/2022, 2:54 AM
    but it seems it produced this error at first
    Copy code
    Puppet Evaluation Error: Error while evaluating a Function Call, Class[Profile::Some_Class::Client]: expects a value for parameter 'my_variable' (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 19, column: 5) on node login1
  • d

    dimitry

    08/17/2022, 2:54 AM
    but it seems it produced the error mentioned above
  • d

    dimitry

    08/17/2022, 2:55 AM
    Copy code
    Puppet Evaluation Error: Error while evaluating a Function Call, Class[Profile::Some_Class::Client]: expects a value for parameter 'my_variable' (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 19, column: 5) on node login1
  • d

    dimitry

    08/17/2022, 2:55 AM
    message has been deleted
  • d

    dimitry

    08/17/2022, 2:55 AM
    message has been deleted
  • d

    dimitry

    08/17/2022, 2:56 AM
    Question: I created a class to create a default user see below:
    Copy code
    class profile::some_user(
    String $my_variable= 'some_string'
    )
    {
      user { $my_variable:
        ensure     => present,
        forcelocal => true,
        gid        => 'some_gid',
        groups     => 'some_group',
        home       => "/${$my_variable}",
        managehome => true,
        notify     => Selinux::Exec_restorecon["/${$my_variable}"],
        uid        => 'some_uid',
      }
    }
    ) and then used the function `ensure_resources(my_user_class, $my_variable)
  • d

    dimitry

    08/17/2022, 2:56 AM
    but it seems it produced this error at first
    Copy code
    Puppet Evaluation Error: Error while evaluating a Function Call, Class[Profile::Some_Class::Client]: expects a value for parameter 'my_variable' (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 19, column: 5) on node login1
  • s

    Slackbot

    08/17/2022, 2:59 AM
    This message was deleted.
    d
    n
    • 3
    • 8
  • d

    dimitry

    08/17/2022, 2:59 AM
    Question: I created a class to create a default user see below:
    Copy code
    class profile::some_user(
    String $my_variable= 'some_string'
    )
    {
      user { $my_variable:
        ensure     => present,
        forcelocal => true,
        gid        => 'some_gid',
        groups     => 'some_group',
        home       => "/${$my_variable}",
        managehome => true,
        notify     => Selinux::Exec_restorecon["/${$my_variable}"],
        uid        => 'some_uid',
      }
    }
    ) and then used the function
    ensure_resources(my_user_class, $my_variable)
    within another class in the same module
  • n

    NickB

    08/17/2022, 2:59 AM
    I think you want
    "/${my_variable}"
  • d

    dimitry

    08/17/2022, 2:59 AM
    then I removed the
    ensure_resources()
    withing the where it was called and did this instead
    include class profile::some_user
    but still complained about the same issue, what is the cause
  • d

    dimitry

    08/17/2022, 3:01 AM
    Question: I created a class to create a default user see below:
    Copy code
    class profile::some_user(
    String $my_variable= 'some_string'
    )
    {
      user { $my_variable:
        ensure     => present,
        forcelocal => true,
        gid        => 'some_gid',
        groups     => 'some_group',
        home       => "/${my_variable}",
        managehome => true,
        notify     => Selinux::Exec_restorecon["/${my_variable}"],
        uid        => 'some_uid',
      }
    }
    ) and then used the function
    ensure_resources(my_user_class, $my_variable)
    within another class in the same module
  • d

    dimitry

    08/17/2022, 3:02 AM
    would you know the reason
  • s

    Slackbot

    08/17/2022, 3:03 AM
    This message was deleted.
    d
    • 2
    • 1
  • d

    dimitry

    08/17/2022, 3:03 AM
    since
    ensure_resources()
    need a hash, I define
    Hash $my_variable
    within Profile:Some Class:Client(
    Hash $my_variable
    )
  • d

    dimitry

    08/17/2022, 3:04 AM
    since
    ensure_resources()
    need a hash, I define
    Hash $my_variable
    within Profile:Some Class:Client(
    Hash $my_variable
    )
  • n

    NickB

    08/17/2022, 3:05 AM
    Sorry, not really familiar with
    ensure_resource
  • d

    dimitry

    08/17/2022, 3:06 AM
    Ohh okay then I have a module and two classes I want to call class A in class B how would I be able to do that?
  • d

    dimitry

    08/17/2022, 3:07 AM
    or how can I clear my
    site.pp file
  • d

    dimitry

    08/17/2022, 3:09 AM
    Ohh okay then I have a module and two classes I want to call class A in class B how would I be able to do that?
1...132133134...428Latest