1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_collection_users.git synced 2024-08-16 10:29:50 +02:00

Merge pull request #20 from roles-ansible/editor

improved editor config
This commit is contained in:
L3D 2024-05-24 11:42:23 +02:00 committed by GitHub
commit 0c32a12b24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 38 additions and 7 deletions

View file

@ -107,8 +107,10 @@ There is also the ``l3d_users__ssh_login`` variable which only supports ``name``
| ``l3d_users__sshd_macs`` | ``['hmac-sha2-512-etm@openssh.com', 'hmac-sha2-256-etm@openssh.com', 'hmac-sha2-512']`` | Used MACs |
| ``l3d_users__sshd_xforwarding`` |``true`` | Enable X-Forwarding |
| ``l3d_users__bashrc`` | ``true`` | Configure bashrc |
| ``l3d_users__root_bashrc`` | ``true`` | Set bashrc for root |
| ``l3d_users__dotfiles__bash_completion_enabled`` | ``true`` | Enable bash completion |
| ``l3d_users__dotfiles__aliases`` | *see [roles/dotfiles/defaults/main.yml](roles/dotfiles/defaults/main.yml)* | A predefined list of usefull aliases for your bash config |
| ``l3d_users__dotfiles__variables`` | *see [defaults/main.yml](defaults/main.yml)* | A predefined list of usefull variables for your bash config |
| ``l3d_users__dotfiles__additional_user_bashrc_lines`` | ``[]`` | variable for additional bashrc lines |
| ``l3d_users__bashrc_path`` | ``$HOME/.local/bin:$HOME/bin:$HOME/.cargo/env:$PATH``| bashrc $PATH |
| ``l3d_users__dotfiles__user_prompt`` | *see [roles/dotfiles/defaults/main.yml](roles/dotfiles/defaults/main.yml)* | PS1 prompt for users |

View file

@ -38,8 +38,10 @@ There is a third directory-variable called ``l3d_users__ssh_login: []`` which on
| name | default value | description |
| --- | --- | --- |
| ``l3d_users__bashrc`` | ``true`` | Configure bashrc |
| ``l3d_users__root_bashrc`` | ``true`` | Set bashrc for root |
| ``l3d_users__dotfiles__bash_completion_enabled`` | ``true`` | Enable bash completion |
| ``l3d_users__dotfiles__aliases`` | *see [defaults/main.yml](defaults/main.yml)* | A predefined list of usefull aliases for your bash config |
| ``l3d_users__dotfiles__variables`` | *see [defaults/main.yml](defaults/main.yml)* | A predefined list of usefull variables for your bash config |
| ``l3d_users__dotfiles__additional_user_bashrc_lines`` | ``[]`` | variable for additional bashrc lines |
| ``l3d_users__bashrc_path`` | ``$HOME/.local/bin:$HOME/bin:$HOME/.cargo/env:$PATH``| bashrc $PATH |
| ``l3d_users__dotfiles__user_prompt`` | *see [defaults/main.yml](defaults/main.yml)* | PS1 prompt for users |

View file

@ -31,6 +31,7 @@ l3d_users__local_users: []
# pubkeys: "{{ lookup('url', 'https://github.com/do1jlr.keys', split_lines=False) }}"
l3d_users__bashrc: true
l3d_users__root_bashrc: true
l3d_users__dotfiles__bash_completion_enabled: true
l3d_users__dotfiles__aliases:
- {alias: "ls", command: "ls ", color: true}
@ -39,13 +40,15 @@ l3d_users__dotfiles__aliases:
- {alias: "la", command: "ls -A", color: false}
- {alias: "l", command: "ls -CF", color: false}
- {alias: "lz", command: "ls -Z", color: false}
- {alias: "EDITOR", command: "/usr/bin/vim", color: false}
- {alias: "VISUAL", command: "/usr/bin/gedit", color: false}
- {alias: "gitsubpull", command: "git submodule foreach '(git checkout \\$(git symbolic-ref --short refs/remotes/origin/HEAD | sed 's@^origin/@@'); git pull ; git submodule foreach \\\"(git checkout \\$(git symbolic-ref --short refs/remotes/origin/HEAD | sed 's@^origin/@@'); git pull)\\\")'", color: false}
- {alias: "pwgen", command: "/usr/bin/pwgen --num-passwords=3000 --numerals --capitalize --secure --no-vowels --ambiguous 95 1", color: false}
- {alias: "gdiff", command: "git diff --submodule=diff", color: false}
- {alias: "ip", command: "ip ", color: true}
l3d_users__dotfiles__variables:
- {var: "EDITOR", command: "/usr/bin/vim"}
- {var: "VISUAL", command: "/usr/bin/gedit"}
l3d_users__dotfiles__additional_user_bashrc_lines: []
l3d_users__bashrc_path: "$HOME/.local/bin:$HOME/bin:$HOME/.cargo/env:$PATH"

View file

@ -6,6 +6,7 @@
dest: '/etc/bash.bashrc'
owner: 'root'
group: 'root'
backup: true
mode: 'u=rw,g=r,o=r'
- name: Create bashrc configuration per user
@ -16,8 +17,20 @@
owner: "{{ user.name }}"
group: "{{ user.name }}"
mode: '0640'
backup: true
loop: "{{ _l3d_users__merged_users }}"
loop_control:
label: "user={{ user.name }}"
loop_var: user
when: user.state | default ('present') == 'present'
- name: Create bashrc for root
become: true
ansible.builtin.template:
src: 'templates/dotbashrc.j2'
dest: "/root/.bashrc"
owner: 'root'
group: 'root'
mode: '0640'
backup: true
when: user.state | default ('present') == 'present'

View file

@ -20,6 +20,11 @@ fi
{% endif %}
{% endfor %}
# set variables
{% for vars in l3d_users__dotfiles__variables %}
export {{ vars.var }}="{{ vars.command }}"
{% endfor %}
{% if l3d_users__dotfiles__bash_completion_enabled %}
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then

View file

@ -1,5 +1,9 @@
{% if user is defined %}
# {{ user.home | default('/home/' + user.name) }}/.bashrc"
# for user {{ user.name }}
{% else %}
# /root/.bashrc
{% endif %}
{{ ansible_managed | ansible.builtin.comment }}
# Source global definitions
@ -40,7 +44,7 @@ fi
# fancy Prompt
export PS1='{{ l3d_users__dotfiles__user_prompt }} '
# baqsh_history
# bash_history
HISTCONTROL={{ l3d_users__dotfiles__history_control }}
shopt -s histappend
{% if ansible_os_family == 'Redhat' %}
@ -59,9 +63,11 @@ HISTFILESIZE={{ l3d_users__dotfiles__history_file_size }}
{{ _row }}
{% endfor %}
{% if user is defined %}
# additional user rules
{% for custom in user.bashrc | default([]) %}
{{ custom }}
{% endfor %}
{% endif %}
# vim:ts=4:sw=4

View file

@ -5,5 +5,5 @@ l3d_users__dotfiles_packages:
- htop
- tmux
playbook_version_number: 9
playbook_version_number: 10
playbook_version_path: 'l3d.users.dotfiles.version'