lookup homedirs

This commit is contained in:
2023-12-29 23:25:04 -05:00
parent b5b233ce78
commit 9cd5776096
3 changed files with 23 additions and 14 deletions

View File

@@ -12,7 +12,6 @@
{% endif %}
{% for user, config in salt.pillar.get('users', {}).items() %}
{{ user }}_user:
user.present:
- name: {{ user }}
@@ -23,8 +22,15 @@
{% endif %}
{% endfor %}
{% if config.get('manage_bashrc', False) %}
/home/{{ user }}/.bashrc:
{% if config.get('manage_bashrc', False) %}
{% set homedir = salt.user.info(user).get('home', None) %}
{% if homedir is none %}
{{ "~%s/.bashrc" | format(user) }}:
test.fail_without_changes:
- name: {{ "No homedir for %s - if they were created in this run, run this state again" | format(user) }}
{% else %}
{{ homedir }}/.bashrc:
file.managed:
- source: 'salt://users/files/bashrc.jinja'
- template: jinja
@@ -35,7 +41,7 @@
bashrc_user: {{ user }}
- require:
- user: {{ user }}_user
{% endif %}
{% endif %}
{% endif %}
{% endfor %}