-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from jordiprats/master
millores varies
- Loading branch information
Showing
17 changed files
with
303 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Puppet::Functions.create_function(:salt_key_status) do |args| | ||
dispatch :salt_key_status do | ||
param 'String', :arg | ||
end | ||
|
||
def salt_key_status(arg) | ||
# salt-key -L --out=txt | grep "'centos7.vm'" | cut -f 1 -d: | ||
command = ['/usr/bin/salt-key -L --out=txt | grep'] | ||
command.push("\"'" + arg + "'\"") | ||
command.push("| cut -f 1 -d:") | ||
|
||
command = command.join ' ' | ||
|
||
output = Puppet::Util::Execution.execute(command, { | ||
:uid => 'root', | ||
:gid => 'root', | ||
:failonfail => false, | ||
:combine => true, | ||
:override_locale => true, | ||
}) | ||
|
||
return output | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
define saltstack::master::acl ( | ||
$user = $name, | ||
$backend = 'pam', | ||
$match = '.*', | ||
) { | ||
include ::saltstack::master | ||
|
||
if(!defined(Concat['/etc/salt/master.d/external_auth.conf'])) | ||
{ | ||
concat { '/etc/salt/master.d/external_auth.conf': | ||
ensure => 'present', | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0600', | ||
require => File['/etc/salt/master.d'], | ||
} | ||
|
||
concat::fragment { 'salt master external_auth header': | ||
target => '/etc/salt/master.d/external_auth.conf', | ||
order => '00', | ||
content => "# puppet managed file\nexternal_auth:\n", | ||
} | ||
} | ||
|
||
if(!defined(Concat::Fragment["salt master external_auth backend ${backend}"])) | ||
{ | ||
concat::fragment { "salt master external_auth backend ${backend}": | ||
target => '/etc/salt/master.d/external_auth.conf', | ||
order => "01-${backend}", | ||
content => " ${backend}:\n", | ||
} | ||
} | ||
|
||
concat::fragment { "salt master external_auth user ${user}": | ||
target => '/etc/salt/master.d/external_auth.conf', | ||
order => "01-${backend}-${user}", | ||
content => template("${module_name}/master/acl.erb"), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# [root@centos7 ~]# salt-key -L --out=txt | ||
# minions_rejected: [] | ||
# minions_denied: [] | ||
# minions_pre: [u'centos7.vm'] | ||
# minions: [u'centos71.vm'] | ||
define saltstack::master::key ( | ||
$hostname = $name, | ||
$status = 'accepted', | ||
) { | ||
include ::saltstack::master | ||
|
||
$current_status = salt_key_status($hostname) | ||
|
||
case $status | ||
{ | ||
'accepted': | ||
{ | ||
case $current_status | ||
{ | ||
/^minions$/: {} | ||
/^minions_/: | ||
{ | ||
exec { "salt-key for ${hostname} from ${current_status} to ${status}": | ||
command => "salt-key -a ${hostname} --include-rejected --include-denied -y", | ||
path => '/usr/sbin:/usr/bin:/sbin:/bin', | ||
} | ||
} | ||
default: { fail("ERROR: current status set as '${current_status}' - desired state: ${status}")} | ||
} | ||
} | ||
'rejected': | ||
{ | ||
case $current_status | ||
{ | ||
/^minions_denied$/, /^minions$/, /^minions_pre$/: | ||
{ | ||
exec { "salt-key for ${hostname} from ${current_status} to ${status}": | ||
command => "salt-key -r ${hostname} --include-accepted --include-denied -y", | ||
path => '/usr/sbin:/usr/bin:/sbin:/bin', | ||
} | ||
} | ||
/^minions_rejected$/: { } | ||
default: { fail("ERROR: current status set as '${current_status}' - desired state: ${status}")} | ||
} | ||
} | ||
default: { fail("Unsupported desired status: ${status}") } | ||
} | ||
} |
Oops, something went wrong.