diff --git a/tasks/system_cfg/main.yml b/tasks/system_cfg/main.yml index 8edec4cd33971891f8320ba75305a83ac5817b0d..373ab9e7f4a7340d5a53ebbcd21c56b047e7f2e0 100644 --- a/tasks/system_cfg/main.yml +++ b/tasks/system_cfg/main.yml @@ -8,13 +8,17 @@ - name: HOSTNAME | setup ansible.builtin.hostname: - name: "{{ ansible_hostname }}" + name: "{{ inventory_hostname }}" - - name: IMPORT_TASKS | firewall - ansible.builtin.import_tasks: firewall.yml + - name: HOSTS | setup + ansible.builtin.template: + dest: "/etc/hosts" + src: templates/etc-hosts.j2 + backup: true + mode: 0640 - - name: IMPORT_TASKS | font - ansible.builtin.import_tasks: font.yml + - name: ANSIBLE | re-gather facts + ansible.builtin.setup: - name: IMPORT_TASKS | ldp ansible.builtin.import_tasks: ldp.yml diff --git a/tasks/system_cfg/shell.yml b/tasks/system_cfg/shell.yml deleted file mode 100644 index 442486196a769d346f09e7316d773458e9a99eaf..0000000000000000000000000000000000000000 --- a/tasks/system_cfg/shell.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: "SHELL | set zsh for {{ my_user }}" - when: inventory_hostname in groups.station - ansible.builtin.user: - name: "{{ my_user }}" - shell: /bin/zsh - state: present diff --git a/tasks/system_cfg/templates/etc-hosts.j2 b/tasks/system_cfg/templates/etc-hosts.j2 new file mode 100644 index 0000000000000000000000000000000000000000..17ee16dd4595888b8da7a6dbe3b0a86056cbbc48 --- /dev/null +++ b/tasks/system_cfg/templates/etc-hosts.j2 @@ -0,0 +1,36 @@ +#jinja2:lstrip_blocks: True +# ############################################# # +# This file is managed by Ansible # +# Manual edition will be overridden # +# https://lab.frogg.it/freezed/ansible-debian # +# ############################################# # + +127.0.0.1 localhost +127.0.1.1 {{ inventory_fqdn }} {{ inventory_hostname }} +{{ ansible_host }} {{ inventory_fqdn }} {{ inventory_hostname }} + +{% if inventory_hostname in groups['station'] or inventory_hostname in groups['backup'] %} +# WAN + {% for host in groups['production'] %} +{{ hostvars[host]['ansible_host'] }} {{ hostvars[host]['inventory_fqdn'] }} {{ host }} + {% endfor %} +{% endif %} + +{% if inventory_hostname in groups['station'] or inventory_hostname in groups['production'] %} +# BKP + {% for host in groups['backup'] %} +{{ hostvars[host]['ansible_host'] }} {{ hostvars[host]['inventory_fqdn'] }} {{ host }} + {% endfor %} +{% endif %} + +{% if inventory_hostname in groups['station'] %} +# DEV + {% for host in groups['devel'] %} +{{ hostvars[host]['ansible_host'] }} {{ hostvars[host]['inventory_fqdn'] }} {{ host }} + {% endfor %} + +# LOCAL + {% for host in groups['station'] %} +{{ hostvars[host]['ansible_host'] }} {{ hostvars[host]['inventory_fqdn'] }} {{ host }} + {% endfor %} +{% endif %} diff --git a/tasks/system_cfg/templates/ssh-config_backup.j2 b/tasks/system_cfg/templates/ssh-config_backup.j2 new file mode 100644 index 0000000000000000000000000000000000000000..82503850d3e33aac97af442d47f6e2487b768ec5 --- /dev/null +++ b/tasks/system_cfg/templates/ssh-config_backup.j2 @@ -0,0 +1,14 @@ +#jinja2:lstrip_blocks: True +# ############################################# # +# This file is managed by Ansible # +# Manual edition will be overridden # +# https://lab.frogg.it/freezed/ansible-debian # +# ############################################# # + +{% for host in groups['production'] %} +Host {{ host }} + User {{ hostvars[host]['my_user'] }} + Hostname {{ hostvars[host]['ansible_host'] }} + Port {{ hostvars[host]['ansible_port'] }} + +{% endfor %}