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;
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
add a comment |
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
add a comment |
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
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
puppet user-management conditional
edited May 6 at 10:21
Mr Shunz
2,29912222
2,29912222
asked May 6 at 10:05
Nithya BeeNithya Bee
82
82
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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 withinline_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 usinginline_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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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 withinline_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 usinginline_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
add a comment |
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.
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 withinline_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 usinginline_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
add a comment |
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.
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.
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 withinline_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 usinginline_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
add a comment |
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 withinline_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 usinginline_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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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