- name: shell environment gather_facts: no hosts: "{{target}}" become: "{{become}}" tasks: # # an architecture a day, keeps a hacker away # # required for gnu/linux vs bsd specific - name: define kernel name ansible.builtin.shell: executable: /bin/bash cmd: uname -s changed_when: false check_mode: false register: kernel - debug: var=kernel.stdout when: kernel.stdout != 'Linux' - debug: var=kernel.stderr when: kernel.stdout != 'Linux' - set_fact: bashrc_location: > {% if system == 'debian' %} /etc/bash.bashrc {% elif system == 'redhat' %} /etc/bashrc {% elif system == 'slackware' %} /etc/shrc {% else %} error unknown system {{system}} - exiting {{0/0}} {% endif %} when: kernel.stdout == 'Linux' # # gnu/linux # - name: system-wide bashrc block ansible.builtin.blockinfile: block: "{{ lookup('file', 'blockinfile/bashrc') }}" path: "{{bashrc_location|trim}}" diff: true when: kernel.stdout == 'Linux' - name: log helper script ansible.builtin.copy: content: "tail -n0 -F /var/log/*\n" dest: /root/log mode: 0755 diff: true when: kernel.stdout == 'Linux' - name: logall helper script ansible.builtin.copy: content: "tail -n0 -F /var/log/* /var/log/*/*\n" dest: /root/logall mode: 0755 diff: true # too many files in /var/log/packages/ when: kernel.stdout == 'Linux' and system != 'slackware' ### slackware - include_tasks: incl-slackware.yml when: system == 'slackware' - include_tasks: incl-slackware-sbo.yml when: system == 'slackware' and sbo is defined ### freebsd - include_tasks: incl-freebsd.yml when: system == 'freebsd' ### shared - include_tasks: incl-shared.yml handlers: - name: reindex files ansible.builtin.shell: executable: /bin/bash cmd: updatedb