Puppet user creation with conditionWhat are some of the pitfalls of reusing a user name in Ubuntu?puppet execution of a python script where os.system(…) command is not workingPuppet - Possible to use software design patterns in modules?puppet: enable / disable recurse directoriesHow to ensure that the «if» statement gets parsed _before_ a given resource/class?How can I use Puppet to Enforce Local Group Membership?Puppet Agent fails to run install.bashPuppet ensure file is directory OR link. Or ensure directory only if absent?Best way for user management with HieraIs there an onlyif equivalent condition that can apply to a Puppet class or to a “file” command in a manifest?

How can I monitor the bulk API limit?

Why does Taylor’s series “work”?

Have the writers and actors of GOT responded to its poor reception?

Physically unpleasant work environment

Managing heat dissipation in a magic wand

Cycling to work - 30mile return

How do you cope with rejection?

Driving a school bus in the USA

Is there any deeper thematic meaning to the white horse that Arya finds in The Bells (S08E05)?

Is it standard to have the first week's pay indefinitely withheld?

Gambler's Fallacy Dice

Should I twist DC power and ground wires from a power supply?

Why does string strummed with finger sound different from the one strummed with pick?

What color to choose as "danger" if the main color of my app is red

Are there any crystals that are theoretically possible, but haven't yet been made?

pwaS eht tirsf dna tasl setterl fo hace dorw

What technology would Dwarves need to forge titanium?

Taylor series leads to two different functions - why?

Failing students when it might cause them economic ruin

Divisor Rich and Poor Numbers

Why is so much ransomware breakable?

How to customize the pie chart background in PowerPoint?

What were the "pills" that were added to solid waste in Apollo 7?

What should I wear to go and sign an employment contract?



Puppet user creation with condition


What are some of the pitfalls of reusing a user name in Ubuntu?puppet execution of a python script where os.system(…) command is not workingPuppet - Possible to use software design patterns in modules?puppet: enable / disable recurse directoriesHow to ensure that the «if» statement gets parsed _before_ a given resource/class?How can I use Puppet to Enforce Local Group Membership?Puppet Agent fails to run install.bashPuppet ensure file is directory OR link. Or ensure directory only if absent?Best way for user management with HieraIs there an onlyif equivalent condition that can apply to a Puppet class or to a “file” command in a manifest?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















How to create user with same UID(only if it doesn't exists) without affecting the servers having the same user with random UIDs.
To give more insight:
1. Maintain a user, "user1" all across the fleet of servers with same UID
2. A considerable number of servers are having the same user with random UID. The puppet class should do nothing in that case



user 'user1':
ensure => present,
comment => 'Appp user',
uid => 55555,
onlyif => <if the user1 is not present> ---> I know there is no attribute called onlyif in 'user'
gid => 55555,
home => '/home/user1',
shell => '/bin/bash',



Any help appreciated.










share|improve this question






























    1















    How to create user with same UID(only if it doesn't exists) without affecting the servers having the same user with random UIDs.
    To give more insight:
    1. Maintain a user, "user1" all across the fleet of servers with same UID
    2. A considerable number of servers are having the same user with random UID. The puppet class should do nothing in that case



    user 'user1':
    ensure => present,
    comment => 'Appp user',
    uid => 55555,
    onlyif => <if the user1 is not present> ---> I know there is no attribute called onlyif in 'user'
    gid => 55555,
    home => '/home/user1',
    shell => '/bin/bash',



    Any help appreciated.










    share|improve this question


























      1












      1








      1








      How to create user with same UID(only if it doesn't exists) without affecting the servers having the same user with random UIDs.
      To give more insight:
      1. Maintain a user, "user1" all across the fleet of servers with same UID
      2. A considerable number of servers are having the same user with random UID. The puppet class should do nothing in that case



      user 'user1':
      ensure => present,
      comment => 'Appp user',
      uid => 55555,
      onlyif => <if the user1 is not present> ---> I know there is no attribute called onlyif in 'user'
      gid => 55555,
      home => '/home/user1',
      shell => '/bin/bash',



      Any help appreciated.










      share|improve this question
















      How to create user with same UID(only if it doesn't exists) without affecting the servers having the same user with random UIDs.
      To give more insight:
      1. Maintain a user, "user1" all across the fleet of servers with same UID
      2. A considerable number of servers are having the same user with random UID. The puppet class should do nothing in that case



      user 'user1':
      ensure => present,
      comment => 'Appp user',
      uid => 55555,
      onlyif => <if the user1 is not present> ---> I know there is no attribute called onlyif in 'user'
      gid => 55555,
      home => '/home/user1',
      shell => '/bin/bash',



      Any help appreciated.







      puppet user-management conditional






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 6 at 10:21









      Mr Shunz

      2,29912222




      2,29912222










      asked May 6 at 10:05









      Nithya BeeNithya Bee

      82




      82




















          1 Answer
          1






          active

          oldest

          votes


















          0














          In order to do what you describe, you'd need a custom Fact to check for the existence of user1 and do something conditionally based on the state on that system.



          Maybe you parameterize UID based on user1 existence. If there's already a user1, don't manage uid.



          $user1_uid = $::user1 ? 
          true => undef,
          default => 55555,


          user 'user1':
          ensure => present,
          comment => 'Appp user',
          uid => $user1_uid,
          gid => 55555,
          home => '/home/user1',
          shell => '/bin/bash',



          Or, worse, wrap your user creation in an Exec resource with a shell script.



          Both of these are not the best options, but given what you have asked this is what you can do. Personally, I'd look into what it would take to migrate the UID of user1 on the systems where it isn't consistent. That might be more of an up front effort, but should pay off over time.




          EDIT:



          I ran a scenario based on your comments and verified my concern. Puppet functions are executed by Puppetserver. So, the conditional you wrote is not dependent on the state of user1 on the client, but on the master.



          I started by adding user1 to a Puppet client system. Then, I took your code and created a file user1.pp.



          $user_id = inline_template("<%= `/usr/bin/getent passwd user1` %>") 
          if ("$user_id" == "")
          user 'user1':
          ensure => present,
          comment => 'App user',
          uid => 61234,
          gid => 61234,
          home => '/home/user1',
          shell => '/bin/bash',

          else
          notify "The group is already present. Skipping..":



          When I executed this file with puppet apply, I get the expected result when the user already exists because the command inside inline_template() is executed locally. (This is the same result if the user existed on the Puppetserver host.)



          [root@localhost ~]# puppet apply /root/user1.pp 
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Main/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 0.15 seconds


          When I put the code on my Puppetserver and run puppet agent, it tries to modify the existing user. You have described this as an undesired result.



          [root@localhost ~]# puppet agent -t
          ...
          Notice: /Stage[main]/User[user1]/uid: uid changed 1000 to 61234
          Error: Could not find group(s) 61234
          Error: /Stage[main]/User[user1]/gid: change from 1000 to 61234 failed: Could not find group(s) 61234
          Notice: /Stage[main]/User[user1]/comment: comment changed '' to 'App user'
          ...


          If the user exists on the Puppetserver but not the client, the user is not added because the getent function returns successfully on the Puppetserver.



          [root@localhost ~]# id user1
          id: user1: no such user
          [root@localhost ~]# puppet agent -t
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 19.73 seconds


          I am afraid that you need to reconsider your solution to get your desired results. If you run your solution you may accidentally change UID.






          share|improve this answer




















          • 1





            Aaron, Thank for your time and a good explanation. Both the ideas are good. But after few trial and error , I used inline template and a 'if' loop. $user_id = inline_template("<%= /usr/bin/getent passwd user1 %>") if("$user_id" == "") user ‘user1’: ensure => present, comment => ‘App user', uid => 61234, gid => 61234, home => '/home/user1’, shell => '/bin/bash', else notify "The group is already present. Skipping..": }

            – Nithya Bee
            May 7 at 10:31







          • 1





            The reason we do this, we have many app servers already started without much pre-planning with random IDs. Now we wanna streamline the configs to reduce further conflict, atleast when the app is restarted for some reason, but at the same can't afford to bring down the running apps.

            – Nithya Bee
            May 7 at 10:39











          • I would have thought with inline_template() being a function (executing on the Puppetserver) you would only return the state of user1 on the Puppetserver rather than on the client. Either way, I am glad that it is working for you. I certainly understand how you got in your current predicament -- it happens. :+1:

            – Aaron Copley
            May 7 at 20:10












          • @NithyaBee I updated my answer so I could include more context and formatting. There is a problem with using inline_template().

            – Aaron Copley
            May 7 at 20:40











          • Thanks Aaron. I dint think of this. Its valuable for me. Appreciate your help.

            – Nithya Bee
            May 9 at 4:37











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "2"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f966025%2fpuppet-user-creation-with-condition%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          In order to do what you describe, you'd need a custom Fact to check for the existence of user1 and do something conditionally based on the state on that system.



          Maybe you parameterize UID based on user1 existence. If there's already a user1, don't manage uid.



          $user1_uid = $::user1 ? 
          true => undef,
          default => 55555,


          user 'user1':
          ensure => present,
          comment => 'Appp user',
          uid => $user1_uid,
          gid => 55555,
          home => '/home/user1',
          shell => '/bin/bash',



          Or, worse, wrap your user creation in an Exec resource with a shell script.



          Both of these are not the best options, but given what you have asked this is what you can do. Personally, I'd look into what it would take to migrate the UID of user1 on the systems where it isn't consistent. That might be more of an up front effort, but should pay off over time.




          EDIT:



          I ran a scenario based on your comments and verified my concern. Puppet functions are executed by Puppetserver. So, the conditional you wrote is not dependent on the state of user1 on the client, but on the master.



          I started by adding user1 to a Puppet client system. Then, I took your code and created a file user1.pp.



          $user_id = inline_template("<%= `/usr/bin/getent passwd user1` %>") 
          if ("$user_id" == "")
          user 'user1':
          ensure => present,
          comment => 'App user',
          uid => 61234,
          gid => 61234,
          home => '/home/user1',
          shell => '/bin/bash',

          else
          notify "The group is already present. Skipping..":



          When I executed this file with puppet apply, I get the expected result when the user already exists because the command inside inline_template() is executed locally. (This is the same result if the user existed on the Puppetserver host.)



          [root@localhost ~]# puppet apply /root/user1.pp 
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Main/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 0.15 seconds


          When I put the code on my Puppetserver and run puppet agent, it tries to modify the existing user. You have described this as an undesired result.



          [root@localhost ~]# puppet agent -t
          ...
          Notice: /Stage[main]/User[user1]/uid: uid changed 1000 to 61234
          Error: Could not find group(s) 61234
          Error: /Stage[main]/User[user1]/gid: change from 1000 to 61234 failed: Could not find group(s) 61234
          Notice: /Stage[main]/User[user1]/comment: comment changed '' to 'App user'
          ...


          If the user exists on the Puppetserver but not the client, the user is not added because the getent function returns successfully on the Puppetserver.



          [root@localhost ~]# id user1
          id: user1: no such user
          [root@localhost ~]# puppet agent -t
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 19.73 seconds


          I am afraid that you need to reconsider your solution to get your desired results. If you run your solution you may accidentally change UID.






          share|improve this answer




















          • 1





            Aaron, Thank for your time and a good explanation. Both the ideas are good. But after few trial and error , I used inline template and a 'if' loop. $user_id = inline_template("<%= /usr/bin/getent passwd user1 %>") if("$user_id" == "") user ‘user1’: ensure => present, comment => ‘App user', uid => 61234, gid => 61234, home => '/home/user1’, shell => '/bin/bash', else notify "The group is already present. Skipping..": }

            – Nithya Bee
            May 7 at 10:31







          • 1





            The reason we do this, we have many app servers already started without much pre-planning with random IDs. Now we wanna streamline the configs to reduce further conflict, atleast when the app is restarted for some reason, but at the same can't afford to bring down the running apps.

            – Nithya Bee
            May 7 at 10:39











          • I would have thought with inline_template() being a function (executing on the Puppetserver) you would only return the state of user1 on the Puppetserver rather than on the client. Either way, I am glad that it is working for you. I certainly understand how you got in your current predicament -- it happens. :+1:

            – Aaron Copley
            May 7 at 20:10












          • @NithyaBee I updated my answer so I could include more context and formatting. There is a problem with using inline_template().

            – Aaron Copley
            May 7 at 20:40











          • Thanks Aaron. I dint think of this. Its valuable for me. Appreciate your help.

            – Nithya Bee
            May 9 at 4:37















          0














          In order to do what you describe, you'd need a custom Fact to check for the existence of user1 and do something conditionally based on the state on that system.



          Maybe you parameterize UID based on user1 existence. If there's already a user1, don't manage uid.



          $user1_uid = $::user1 ? 
          true => undef,
          default => 55555,


          user 'user1':
          ensure => present,
          comment => 'Appp user',
          uid => $user1_uid,
          gid => 55555,
          home => '/home/user1',
          shell => '/bin/bash',



          Or, worse, wrap your user creation in an Exec resource with a shell script.



          Both of these are not the best options, but given what you have asked this is what you can do. Personally, I'd look into what it would take to migrate the UID of user1 on the systems where it isn't consistent. That might be more of an up front effort, but should pay off over time.




          EDIT:



          I ran a scenario based on your comments and verified my concern. Puppet functions are executed by Puppetserver. So, the conditional you wrote is not dependent on the state of user1 on the client, but on the master.



          I started by adding user1 to a Puppet client system. Then, I took your code and created a file user1.pp.



          $user_id = inline_template("<%= `/usr/bin/getent passwd user1` %>") 
          if ("$user_id" == "")
          user 'user1':
          ensure => present,
          comment => 'App user',
          uid => 61234,
          gid => 61234,
          home => '/home/user1',
          shell => '/bin/bash',

          else
          notify "The group is already present. Skipping..":



          When I executed this file with puppet apply, I get the expected result when the user already exists because the command inside inline_template() is executed locally. (This is the same result if the user existed on the Puppetserver host.)



          [root@localhost ~]# puppet apply /root/user1.pp 
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Main/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 0.15 seconds


          When I put the code on my Puppetserver and run puppet agent, it tries to modify the existing user. You have described this as an undesired result.



          [root@localhost ~]# puppet agent -t
          ...
          Notice: /Stage[main]/User[user1]/uid: uid changed 1000 to 61234
          Error: Could not find group(s) 61234
          Error: /Stage[main]/User[user1]/gid: change from 1000 to 61234 failed: Could not find group(s) 61234
          Notice: /Stage[main]/User[user1]/comment: comment changed '' to 'App user'
          ...


          If the user exists on the Puppetserver but not the client, the user is not added because the getent function returns successfully on the Puppetserver.



          [root@localhost ~]# id user1
          id: user1: no such user
          [root@localhost ~]# puppet agent -t
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 19.73 seconds


          I am afraid that you need to reconsider your solution to get your desired results. If you run your solution you may accidentally change UID.






          share|improve this answer




















          • 1





            Aaron, Thank for your time and a good explanation. Both the ideas are good. But after few trial and error , I used inline template and a 'if' loop. $user_id = inline_template("<%= /usr/bin/getent passwd user1 %>") if("$user_id" == "") user ‘user1’: ensure => present, comment => ‘App user', uid => 61234, gid => 61234, home => '/home/user1’, shell => '/bin/bash', else notify "The group is already present. Skipping..": }

            – Nithya Bee
            May 7 at 10:31







          • 1





            The reason we do this, we have many app servers already started without much pre-planning with random IDs. Now we wanna streamline the configs to reduce further conflict, atleast when the app is restarted for some reason, but at the same can't afford to bring down the running apps.

            – Nithya Bee
            May 7 at 10:39











          • I would have thought with inline_template() being a function (executing on the Puppetserver) you would only return the state of user1 on the Puppetserver rather than on the client. Either way, I am glad that it is working for you. I certainly understand how you got in your current predicament -- it happens. :+1:

            – Aaron Copley
            May 7 at 20:10












          • @NithyaBee I updated my answer so I could include more context and formatting. There is a problem with using inline_template().

            – Aaron Copley
            May 7 at 20:40











          • Thanks Aaron. I dint think of this. Its valuable for me. Appreciate your help.

            – Nithya Bee
            May 9 at 4:37













          0












          0








          0







          In order to do what you describe, you'd need a custom Fact to check for the existence of user1 and do something conditionally based on the state on that system.



          Maybe you parameterize UID based on user1 existence. If there's already a user1, don't manage uid.



          $user1_uid = $::user1 ? 
          true => undef,
          default => 55555,


          user 'user1':
          ensure => present,
          comment => 'Appp user',
          uid => $user1_uid,
          gid => 55555,
          home => '/home/user1',
          shell => '/bin/bash',



          Or, worse, wrap your user creation in an Exec resource with a shell script.



          Both of these are not the best options, but given what you have asked this is what you can do. Personally, I'd look into what it would take to migrate the UID of user1 on the systems where it isn't consistent. That might be more of an up front effort, but should pay off over time.




          EDIT:



          I ran a scenario based on your comments and verified my concern. Puppet functions are executed by Puppetserver. So, the conditional you wrote is not dependent on the state of user1 on the client, but on the master.



          I started by adding user1 to a Puppet client system. Then, I took your code and created a file user1.pp.



          $user_id = inline_template("<%= `/usr/bin/getent passwd user1` %>") 
          if ("$user_id" == "")
          user 'user1':
          ensure => present,
          comment => 'App user',
          uid => 61234,
          gid => 61234,
          home => '/home/user1',
          shell => '/bin/bash',

          else
          notify "The group is already present. Skipping..":



          When I executed this file with puppet apply, I get the expected result when the user already exists because the command inside inline_template() is executed locally. (This is the same result if the user existed on the Puppetserver host.)



          [root@localhost ~]# puppet apply /root/user1.pp 
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Main/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 0.15 seconds


          When I put the code on my Puppetserver and run puppet agent, it tries to modify the existing user. You have described this as an undesired result.



          [root@localhost ~]# puppet agent -t
          ...
          Notice: /Stage[main]/User[user1]/uid: uid changed 1000 to 61234
          Error: Could not find group(s) 61234
          Error: /Stage[main]/User[user1]/gid: change from 1000 to 61234 failed: Could not find group(s) 61234
          Notice: /Stage[main]/User[user1]/comment: comment changed '' to 'App user'
          ...


          If the user exists on the Puppetserver but not the client, the user is not added because the getent function returns successfully on the Puppetserver.



          [root@localhost ~]# id user1
          id: user1: no such user
          [root@localhost ~]# puppet agent -t
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 19.73 seconds


          I am afraid that you need to reconsider your solution to get your desired results. If you run your solution you may accidentally change UID.






          share|improve this answer















          In order to do what you describe, you'd need a custom Fact to check for the existence of user1 and do something conditionally based on the state on that system.



          Maybe you parameterize UID based on user1 existence. If there's already a user1, don't manage uid.



          $user1_uid = $::user1 ? 
          true => undef,
          default => 55555,


          user 'user1':
          ensure => present,
          comment => 'Appp user',
          uid => $user1_uid,
          gid => 55555,
          home => '/home/user1',
          shell => '/bin/bash',



          Or, worse, wrap your user creation in an Exec resource with a shell script.



          Both of these are not the best options, but given what you have asked this is what you can do. Personally, I'd look into what it would take to migrate the UID of user1 on the systems where it isn't consistent. That might be more of an up front effort, but should pay off over time.




          EDIT:



          I ran a scenario based on your comments and verified my concern. Puppet functions are executed by Puppetserver. So, the conditional you wrote is not dependent on the state of user1 on the client, but on the master.



          I started by adding user1 to a Puppet client system. Then, I took your code and created a file user1.pp.



          $user_id = inline_template("<%= `/usr/bin/getent passwd user1` %>") 
          if ("$user_id" == "")
          user 'user1':
          ensure => present,
          comment => 'App user',
          uid => 61234,
          gid => 61234,
          home => '/home/user1',
          shell => '/bin/bash',

          else
          notify "The group is already present. Skipping..":



          When I executed this file with puppet apply, I get the expected result when the user already exists because the command inside inline_template() is executed locally. (This is the same result if the user existed on the Puppetserver host.)



          [root@localhost ~]# puppet apply /root/user1.pp 
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Main/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 0.15 seconds


          When I put the code on my Puppetserver and run puppet agent, it tries to modify the existing user. You have described this as an undesired result.



          [root@localhost ~]# puppet agent -t
          ...
          Notice: /Stage[main]/User[user1]/uid: uid changed 1000 to 61234
          Error: Could not find group(s) 61234
          Error: /Stage[main]/User[user1]/gid: change from 1000 to 61234 failed: Could not find group(s) 61234
          Notice: /Stage[main]/User[user1]/comment: comment changed '' to 'App user'
          ...


          If the user exists on the Puppetserver but not the client, the user is not added because the getent function returns successfully on the Puppetserver.



          [root@localhost ~]# id user1
          id: user1: no such user
          [root@localhost ~]# puppet agent -t
          ...
          Notice: The group is already present. Skipping..
          Notice: /Stage[main]/Notify[The group is already present. Skipping..]/message: defined 'message' as 'The group is already present. Skipping..'
          Notice: Applied catalog in 19.73 seconds


          I am afraid that you need to reconsider your solution to get your desired results. If you run your solution you may accidentally change UID.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 7 at 20:45

























          answered May 6 at 13:56









          Aaron CopleyAaron Copley

          9,98123561




          9,98123561







          • 1





            Aaron, Thank for your time and a good explanation. Both the ideas are good. But after few trial and error , I used inline template and a 'if' loop. $user_id = inline_template("<%= /usr/bin/getent passwd user1 %>") if("$user_id" == "") user ‘user1’: ensure => present, comment => ‘App user', uid => 61234, gid => 61234, home => '/home/user1’, shell => '/bin/bash', else notify "The group is already present. Skipping..": }

            – Nithya Bee
            May 7 at 10:31







          • 1





            The reason we do this, we have many app servers already started without much pre-planning with random IDs. Now we wanna streamline the configs to reduce further conflict, atleast when the app is restarted for some reason, but at the same can't afford to bring down the running apps.

            – Nithya Bee
            May 7 at 10:39











          • I would have thought with inline_template() being a function (executing on the Puppetserver) you would only return the state of user1 on the Puppetserver rather than on the client. Either way, I am glad that it is working for you. I certainly understand how you got in your current predicament -- it happens. :+1:

            – Aaron Copley
            May 7 at 20:10












          • @NithyaBee I updated my answer so I could include more context and formatting. There is a problem with using inline_template().

            – Aaron Copley
            May 7 at 20:40











          • Thanks Aaron. I dint think of this. Its valuable for me. Appreciate your help.

            – Nithya Bee
            May 9 at 4:37












          • 1





            Aaron, Thank for your time and a good explanation. Both the ideas are good. But after few trial and error , I used inline template and a 'if' loop. $user_id = inline_template("<%= /usr/bin/getent passwd user1 %>") if("$user_id" == "") user ‘user1’: ensure => present, comment => ‘App user', uid => 61234, gid => 61234, home => '/home/user1’, shell => '/bin/bash', else notify "The group is already present. Skipping..": }

            – Nithya Bee
            May 7 at 10:31







          • 1





            The reason we do this, we have many app servers already started without much pre-planning with random IDs. Now we wanna streamline the configs to reduce further conflict, atleast when the app is restarted for some reason, but at the same can't afford to bring down the running apps.

            – Nithya Bee
            May 7 at 10:39











          • I would have thought with inline_template() being a function (executing on the Puppetserver) you would only return the state of user1 on the Puppetserver rather than on the client. Either way, I am glad that it is working for you. I certainly understand how you got in your current predicament -- it happens. :+1:

            – Aaron Copley
            May 7 at 20:10












          • @NithyaBee I updated my answer so I could include more context and formatting. There is a problem with using inline_template().

            – Aaron Copley
            May 7 at 20:40











          • Thanks Aaron. I dint think of this. Its valuable for me. Appreciate your help.

            – Nithya Bee
            May 9 at 4:37







          1




          1





          Aaron, Thank for your time and a good explanation. Both the ideas are good. But after few trial and error , I used inline template and a 'if' loop. $user_id = inline_template("<%= /usr/bin/getent passwd user1 %>") if("$user_id" == "") user ‘user1’: ensure => present, comment => ‘App user', uid => 61234, gid => 61234, home => '/home/user1’, shell => '/bin/bash', else notify "The group is already present. Skipping..": }

          – Nithya Bee
          May 7 at 10:31






          Aaron, Thank for your time and a good explanation. Both the ideas are good. But after few trial and error , I used inline template and a 'if' loop. $user_id = inline_template("<%= /usr/bin/getent passwd user1 %>") if("$user_id" == "") user ‘user1’: ensure => present, comment => ‘App user', uid => 61234, gid => 61234, home => '/home/user1’, shell => '/bin/bash', else notify "The group is already present. Skipping..": }

          – Nithya Bee
          May 7 at 10:31





          1




          1





          The reason we do this, we have many app servers already started without much pre-planning with random IDs. Now we wanna streamline the configs to reduce further conflict, atleast when the app is restarted for some reason, but at the same can't afford to bring down the running apps.

          – Nithya Bee
          May 7 at 10:39





          The reason we do this, we have many app servers already started without much pre-planning with random IDs. Now we wanna streamline the configs to reduce further conflict, atleast when the app is restarted for some reason, but at the same can't afford to bring down the running apps.

          – Nithya Bee
          May 7 at 10:39













          I would have thought with inline_template() being a function (executing on the Puppetserver) you would only return the state of user1 on the Puppetserver rather than on the client. Either way, I am glad that it is working for you. I certainly understand how you got in your current predicament -- it happens. :+1:

          – Aaron Copley
          May 7 at 20:10






          I would have thought with inline_template() being a function (executing on the Puppetserver) you would only return the state of user1 on the Puppetserver rather than on the client. Either way, I am glad that it is working for you. I certainly understand how you got in your current predicament -- it happens. :+1:

          – Aaron Copley
          May 7 at 20:10














          @NithyaBee I updated my answer so I could include more context and formatting. There is a problem with using inline_template().

          – Aaron Copley
          May 7 at 20:40





          @NithyaBee I updated my answer so I could include more context and formatting. There is a problem with using inline_template().

          – Aaron Copley
          May 7 at 20:40













          Thanks Aaron. I dint think of this. Its valuable for me. Appreciate your help.

          – Nithya Bee
          May 9 at 4:37





          Thanks Aaron. I dint think of this. Its valuable for me. Appreciate your help.

          – Nithya Bee
          May 9 at 4:37

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f966025%2fpuppet-user-creation-with-condition%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

          Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

          What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company