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

    NickB

    08/17/2022, 3:12 AM
    If you have class foo and want to use it inside class bar
    Copy code
    class bar(
      String $param = 'value',
    ) 
    {
      class { 'foo':
        <foo's params>
      }
    }
  • n

    NickB

    08/17/2022, 3:13 AM
    If you have class foo and want to use class bar inside it
    Copy code
    class bar(
      String $param = 'value',
    ) {
      class { 'foo':
        <foo's params>
      }
  • n

    NickB

    08/17/2022, 3:13 AM
    If you have class foo and want to use class bar inside it
    Copy code
    class bar(
      String $param = 'value',
    ) 
    {
      class { 'foo':
        <foo's params>
      }
    }
  • n

    NickB

    08/17/2022, 3:13 AM
    If you have class foo and want to use it inside class bar
    Copy code
    class bar(
      String $param = 'value',
    ) 
    {
      class { 'foo':
        <foo's params>
      }
    }
  • d

    dimitry

    08/17/2022, 3:28 AM
    its not clear
  • d

    dimitry

    08/17/2022, 3:29 AM
    Copy code
    class bar(
      String $param = 'value',
    ) 
    {
      class { 'foo':
        <foo's $params>
      }
    }
  • d

    dimitry

    08/17/2022, 3:30 AM
    was it missing the $
  • d

    dimitry

    08/17/2022, 3:34 AM
    exxample:
    Copy code
    class profille::some_stuff(String $reference_to_user_class){
    }
    
    class user: {
      user { 'you':
      uid   => 'some_value',
      gid   => 'some_gid',
      group => 'some_group',
      home  => '/you' 
     }
    }
  • d

    dimitry

    08/17/2022, 3:34 AM
    how woul i call the class user in
    class profille::some_stuff
  • d

    dimitry

    08/17/2022, 3:40 AM
    but do you know how to reset site.pp file
  • n

    NickB

    08/17/2022, 3:42 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use classes and types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how some of this stuff works and files are laid out.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, there must be something strange going on in some other manifest that’s trying to use this class, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here. There should be no other
    user
    resources with the same title (in the example above, whatever the value of
    $my_user
    is), including using
    ensure_resource
    with that name (unless you provide the exact parameters declared in the other place you are using that resource, but I would probably just avoid using ensure_resource unless you really need it).
  • n

    NickB

    08/17/2022, 3:43 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to get up to speed on all this. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how the Puppet language works.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, you’ve got some duplicate declarations (resources with the same name) going on in some other manifest, perhaps.
  • n

    NickB

    08/17/2022, 3:55 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use these types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how the Puppet language works.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, you’ve got some duplicate declarations (resources with the same name) going on in some other manifest, perhaps.
  • n

    NickB

    08/17/2022, 3:57 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use these types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how the Puppet language works.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, you’ve got some duplicate declarations (resources with the same name) going on in some other manifest, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here.
  • n

    NickB

    08/17/2022, 3:58 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use classes and types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how the Puppet language works.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, you’ve got some duplicate declarations (resources with the same name) going on in some other manifest, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here.
  • d

    dimitry

    08/17/2022, 3:59 AM
    thanks
  • n

    NickB

    08/17/2022, 3:59 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use classes and types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how the Puppet language works.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, you’ve got some duplicate declarations (resources with the same name) going on in some other manifest, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here. There should be no other
    user
    resources with the same title (in this case, whatever the value of
    $my_user
    is), including using
    ensure_resource
    with that name.
  • n

    NickB

    08/17/2022, 4:00 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use classes and types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how some of this stuff works and files are laid out.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, you’ve got some duplicate declarations (resources with the same name) going on in some other manifest, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here. There should be no other
    user
    resources with the same title (in this case, whatever the value of
    $my_user
    is), including using
    ensure_resource
    with that name.
  • n

    NickB

    08/17/2022, 4:03 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use classes and types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how some of this stuff works and files are laid out.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, you’ve got some duplicate declarations (resources with the same name) going on in some other manifest, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here. There should be no other
    user
    resources with the same title (in the example above, whatever the value of
    $my_user
    is), including using
    ensure_resource
    with that name.
  • n

    NickB

    08/17/2022, 4:04 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use classes and types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how some of this stuff works and files are laid out.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, there must be something strange going on in some other manifest that’s trying to use this class, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here. There should be no other
    user
    resources with the same title (in the example above, whatever the value of
    $my_user
    is), including using
    ensure_resource
    with that name.
  • n

    NickB

    08/17/2022, 4:09 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use classes and types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how some of this stuff works and files are laid out.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, there must be something strange going on in some other manifest that’s trying to use this class, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here. There should be no other
    user
    resources with the same title (in the example above, whatever the value of
    $my_user
    is), including using
    ensure_resource
    with that name (unless you provide the exact parameters declared in the other place you are using that resource, but I probably just avoid using ensure_resource).
  • n

    NickB

    08/17/2022, 4:09 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use classes and types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how some of this stuff works and files are laid out.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, there must be something strange going on in some other manifest that’s trying to use this class, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here. There should be no other
    user
    resources with the same title (in the example above, whatever the value of
    $my_user
    is), including using
    ensure_resource
    with that name (unless you provide the exact parameters declared in the other place you are using that resource, but I would probably just avoid using ensure_resource).
  • n

    NickB

    08/17/2022, 4:10 AM
    user
    is not a class, it’s a resource type. I’d suggest scouring https://puppet.com/docs/puppet/7/puppet_language.html to see how to use classes and types. Also, https://puppet.com/try-puppet/puppet-learning-vm/ is a bit more Puppet Enterprise-based, but you can get an idea of how some of this stuff works and files are laid out.
    Copy code
    class profile::some_stuff(
      String $my_user = 'default_username',
    )
    {
      user { $my_user:
        home => "/${my_user}",
      }
    }
    Should work. If it doesn’t, there must be something strange going on in some other manifest that’s trying to use this class, perhaps. What you had before seemed right besides the typo, so there must be other manifests in play here. There should be no other
    user
    resources with the same title (in the example above, whatever the value of
    $my_user
    is), including using
    ensure_resource
    with that name (unless you provide the exact parameters declared in the other place you are using that resource, but I would probably just avoid using ensure_resource unless you really need it).
  • d

    dimitry

    08/17/2022, 4:12 AM
    btw here this is the class that I created main class:
    Copy code
    class some::other::class( has $user){
    ...
    # Creates the resource if it does not exist, update if needed otherwise do nothing
    ensure_resources(profile::some_user, $user)
    }
    Define after second class above
    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',
      }
    }
  • d

    dimitry

    08/17/2022, 4:13 AM
    this is where all error occured
  • n

    NickB

    08/17/2022, 4:14 AM
    Instead of the top one, do:
    Copy code
    class some::other::class(
      String $user,
    ) {
      class { 'profile::some_user':
        my_variable => $user,
      }
    }
  • n

    NickB

    08/17/2022, 4:14 AM
    Instead of the top one, do:
    Copy code
    class some::other::class(
      String $user,
    ) {
      class { 'profile::some_user':
        my_variable => $user,
      }
    }
  • n

    NickB

    08/17/2022, 4:15 AM
    Then in site.pp (or some other place you are applying classes to a node):
    Copy code
    node mynode {
      class { 'some::other::class':
        user => 'the_user_i_want_to_create',
      }
    }
  • n

    NickB

    08/17/2022, 4:27 AM
    Then in site.pp (or some other place you are applying classes to a node):
    Copy code
    node mynode {
      class { 'some::other::class':
        user => 'the_user_i_want_to_create',
      }
    }
  • n

    NickB

    08/17/2022, 4:34 AM
    Looks like
    ensure_resource('class', 'profile::some_user', { my_variable => $user })
    would probably work in your main class
1...133134135...428Latest