make distinction between bash and csh shell config

This commit is contained in:
Vincent Van der Kussen 2018-08-18 14:07:19 +02:00
parent 95e4ee8c06
commit c53f502220
4 changed files with 49 additions and 12 deletions

View file

@ -17,7 +17,7 @@ users:
keys:
- file: key1
state: present
shell_lines:
bash_lines:
- line: "testline"
state: present
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
@ -30,6 +30,6 @@ users:
keys:
- file: key2
state: absent
shell_lines:
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
csh_lines:
- line: "alias ls ls -lah"
state: present

View file

@ -11,14 +11,15 @@ Ansible roles to create/configure users on Linux/FreeBSD.
| users | | |
| ---: |---| ---|
| _variable name_ | Description | Data type |
| _variable name_ | Description | Data type |
| name | username | string |
| state | whether the user should be created or removed | present/absent |
| password | string of an encrypted value(1) | string |
| groups | additional groups the user should belong to | list |
| uid | optionally specify a user id | int |
| keys | list of dictionaries | list |
| shell_lines | list of dictionaries | list |
| bash_lines | configure lines in .bashrc | list |
| csh_lines | configure lines in .cshrc | list |
(1) https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module
## Default variables
@ -47,7 +48,7 @@ users:
keys:
- file: key1
state: present
shell_lines:
bash_lines:
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls lah'"
@ -56,8 +57,8 @@ users:
keys:
- file: key2
state: absent
shell_lines:
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
csh_lines:
- line: "ls ls -lah"
state: absent
```
## Using the Role

View file

@ -1,4 +1,40 @@
default_freebsd_shell: "/bin/csh"
default_linux_shell: "/bin/bash"
default_shell_lines:
- SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh
# Example variables
#---
#user_groups:
# - name: mygroup
# gid: 700
# - name: mysecondgroup
# gid: 702
# state: absent
#
#
#users:
# - name: remember
# state: present
# password: "blabla"
# groups:
# - mygroup
# uid: 1100
# keys:
# - file: key1
# state: present
# bash_lines:
# - line: "testline"
# state: present
# - line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
# state: present
# - line: "alias ls='ls lah'"
# state: present
# ssh_config:
# - ServerAliveInterval: 10
# - name: test
# keys:
# - file: key2
# state: absent
# csh_lines:
# - line: "alias ls ls -lah"
# state: present

View file

@ -28,7 +28,7 @@
backup: yes
with_subelements:
- "{{ users }}"
- shell_lines
- bash_lines
- skip_missing: true
when: ansible_os_family == 'Debian'
@ -40,7 +40,7 @@
state: "{{ item.1.state | default('present')}}"
with_subelements:
- "{{ users }}"
- shell_lines
- csh_lines
- skip_missing: true
when: ansible_os_family == 'FreeBSD'