ansible-roles/evolinux-base/tasks/root.yml

81 lines
1.8 KiB
YAML

---
- name: chmod 700 /root
file:
path: /root
state: directory
mode: "700"
when: evolinux_root_chmod
- name: "Customize root's bashrc..."
lineinfile:
dest: /root/.bashrc
line: "{{ item }}"
create: yes
state: present
with_items:
- "export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoreboth"
- "export HISTSIZE=65535"
- "export HISTTIMEFORMAT=\"%c : \""
when: evolinux_root_bashrc
## .bash_history should be append-only
- name: Create .bash_history if missing
copy:
content: ""
dest: "/root/.bash_history"
force: no
when: evolinux_root_bash_history
- name: Set umask in /root/.profile
lineinfile:
dest: "/root/.profile"
line: "umask 0077"
regexp: "umask [0-9]+"
when: evolinux_root_umask
- name: Custom git config for root
copy:
src: root/gitconfig
dest: "/root/.gitconfig"
force: no
when: evolinux_root_gitconfig
- name: Is .bash_history append-only
shell: lsattr /root/.bash_history | grep -E "^.*a.* "
register: bash_history_append_only
failed_when: False
changed_when: False
- name: Set .bash_history append-only
command: chattr +a /root/.bash_history
when: evolinux_root_bash_history_appendonly and bash_history_append_only.rc != 0
- name: Setting vim as selected-editor
lineinfile:
dest: /root/.selected_editor
regexp: '^SELECTED_EDITOR='
line: "SELECTED_EDITOR=\"/usr/bin/vim.basic\""
create: yes
when: evolinux_root_vim_default
- name: Setting vim root configuration
lineinfile:
dest: /root/.vimrc
line: "{{ item }}"
create: yes
state: present
with_items:
- "syntax on"
- "set hlsearch"
- "set background=dark"
- "set expandtab"
- "set tabstop=4"
- "set softtabstop=0"
- "set shiftwidth=4"
- "set smarttab"
when: evolinux_root_vim_conf
- meta: flush_handlers