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

          Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

          Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

          Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020