Puppet 6 和模块 puppetlabs/accounts hiera yaml 不填充内容
Puppet 6 and module puppetlabs/accounts hiera yaml does not fill content
我正在尝试将我的用户帐户定义为 Hiera 中的哈希,如下所示:
---
accounts::user:
jack:
ensure: present
bashrc_content: file('accounts/shell/bashrc')
bash_profile_content: file('accounts/shell/bash_profile')
如果我在我的 *.pp 文件中定义它们,它工作正常。
请在 Gist
上查找有关 hiera.yaml、清单和 users.yamal 的更多详细信息
为什么这不起作用?
P.S。 、
不,你想做的事是不可能的。
我有几个选项供您选择。在 Hiera 中,除了调用 file()
函数之外,您可以获得所有数据:
---
accounts::user:
jack:
locked: false
comment: Jack Doe
ensure: present
groups:
- admins
- sudo
shell: '/bin/bash'
home_mode: '0700'
purge_sshkeys: false
managehome: true
managevim: false
sshkeys:
- ssh-rsa AAAA
password: '70'
然后在您的清单中:
$defaults = {
'bashrc_content' => file('accounts/shell/bashrc'),
'bash_profile_content' => file('accounts/shell/bash_profile'),
}
$user_data = lookup('accounts::user', Hash[String,Hash], 'hash', {})
$user_data.each |$user,$props| {
accounts::user { $user: * => $props + $defaults }
}
另一种选择是将您的文件内容简单地包含在 YAML 数据中,即
---
accounts::user:
jack:
locked: false
comment: Jack Doe
ensure: present
groups:
- admins
- sudo
shell: '/bin/bash'
home_mode: '0700'
purge_sshkeys: false
managehome: true
managevim: false
bashrc_content: |
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
if [ -f /etc/bashrc ]; then
. /etc/bashrc # --> Read /etc/bashrc, if present.
fi
...
bash_profile_content: ...
sshkeys:
- ssh-rsa AAAA
password: '70'
那么你根本不需要文件功能或文件。
更多信息:
我正在尝试将我的用户帐户定义为 Hiera 中的哈希,如下所示:
---
accounts::user:
jack:
ensure: present
bashrc_content: file('accounts/shell/bashrc')
bash_profile_content: file('accounts/shell/bash_profile')
如果我在我的 *.pp 文件中定义它们,它工作正常。
请在 Gist
上查找有关 hiera.yaml、清单和 users.yamal 的更多详细信息为什么这不起作用?
P.S。
不,你想做的事是不可能的。
我有几个选项供您选择。在 Hiera 中,除了调用 file()
函数之外,您可以获得所有数据:
---
accounts::user:
jack:
locked: false
comment: Jack Doe
ensure: present
groups:
- admins
- sudo
shell: '/bin/bash'
home_mode: '0700'
purge_sshkeys: false
managehome: true
managevim: false
sshkeys:
- ssh-rsa AAAA
password: '70'
然后在您的清单中:
$defaults = {
'bashrc_content' => file('accounts/shell/bashrc'),
'bash_profile_content' => file('accounts/shell/bash_profile'),
}
$user_data = lookup('accounts::user', Hash[String,Hash], 'hash', {})
$user_data.each |$user,$props| {
accounts::user { $user: * => $props + $defaults }
}
另一种选择是将您的文件内容简单地包含在 YAML 数据中,即
---
accounts::user:
jack:
locked: false
comment: Jack Doe
ensure: present
groups:
- admins
- sudo
shell: '/bin/bash'
home_mode: '0700'
purge_sshkeys: false
managehome: true
managevim: false
bashrc_content: |
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
if [ -f /etc/bashrc ]; then
. /etc/bashrc # --> Read /etc/bashrc, if present.
fi
...
bash_profile_content: ...
sshkeys:
- ssh-rsa AAAA
password: '70'
那么你根本不需要文件功能或文件。
更多信息: