aptly-formula
aptly-formula copied to clipboard
default aptly user creation fails
...with the following error:
----------
ID: aptly_user
Function: user.present
Name: aptly
Result: False
Comment: Failed to create new user aptly
Started: 13:14:41.167389
Duration: 24.448 ms
Changes:
in the logs state is rendered as below:
aptly_user:
group.present:
- name: aptly
user.present:
- name: aptly
- shell: /bin/bash
- home: /var/lib/aptly
- require:
- pkg: aptly_packages
command fails with:
[INFO ] Running state [aptly] at time 13:14:41.167389
[INFO ] Executing state user.present for [aptly]
[DEBUG ] LazyLoaded shadow.info
[DEBUG ] LazyLoaded user.info
[INFO ] Executing command useradd in directory '/root'
[ERROR ] Command 'useradd' failed with return code: 9
[ERROR ] stderr: useradd: group aptly exists - if you want to add this user to that group, use -g.
[ERROR ] retcode: 9
[ERROR ] Failed to create new user aptly
[INFO ] Completed state [aptly] at time 13:14:41.191837 (duration_in_ms=24.448)
here: https://github.com/saltstack-formulas/aptly-formula/blob/be02d7508caf413388c8a3ddd0f05858f9b2d30d/aptly/init.sls#L43-L49 otherwise salt.user.present complains as we already created a group.
to fix it just add else:
{% if aptly.user.gid %}
- gid: {{ aptly.user.gid }}
- gid_from_name: True
{% else %}
- gid: {{ aptly.groupname }}
{% endif %}
let me know if I misunderstood something.