diff --git a/defaults/main.yml b/defaults/main.yml index e7f24ef65dfa5303168fdcc2a4df7c9799106b17..acfc252d261cb44196f3e35f01a1d6de2645b009 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1 +1 @@ -tunnel_user_name: 'systunnel' +tunnel_user_name: systunnel diff --git a/tasks/main.yml b/tasks/main.yml index 407965bd1e3bba114a22b1a71695efc9cf780889..b11929ce68b31ff913b88156f0163c5a11cbb3ce 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,53 +1,56 @@ --- # file: roles/commonconnect/tasks/main.yml -- name: "Common Connect Role" +- name: Common Connect Role set_fact: role_commonconnect_started: true - tags: 'always' + tags: + - always - block: - - name: "Create The /etc/hosts File" + - name: Create The /etc/hosts File template: - src: 'etc_hosts.jinja2' - dest: '/etc/hosts' - owner: 'root' - group: 'root' - mode: '644' + src: etc_hosts.jinja2 + dest: /etc/hosts + owner: root + group: root + mode: 644 - - name: "Copy SSH Config For Server-To-Server Communication For Admins" + - name: Copy SSH Config For Server-To-Server Communication For Admins template: - src: 'ssh_config.jinja2' - dest: '/home/{{ item }}/.ssh/config' + src: ssh_config.jinja2 + dest: /home/{{ item }}/.ssh/config owner: '{{ item }}' - group: 'root' - mode: '644' + group: root + mode: 644 with_flattened: - - '{{ admins|default([]) }}' - - '{{ jailusers|default([]) }}' + - {{ admins|default([]) }} + - {{ jailusers|default([]) }} - block: - - name: "Read available variable cache files" - shell: 'ls ~/.ansible/hostvars' + - name: Read available variable cache files + shell: ls ~/.ansible/hostvars become: no register: variable_files failed_when: false changed_when: false ignore_errors: true - tags: 'always' + tags: + - always - - include_tasks: 'more.yml' + - include_tasks: more.yml with_items: '{{ variable_files.stdout_lines|default([]) }}' loop_control: loop_var: inventory_name when: lookup('pipe','hostname') == inventory_hostname - - name: 'Remember that this role had been run' + - name: Remember that this role had been run set_fact: role_commonconnect_completed: true - tags: 'always' + tags: + - always - when: '"commonconnect" not in excluded_roles and role_commonconnect_completed is not defined' + when: not excluded_roles or "commonconnect" not in excluded_roles and role_commonconnect_completed is not defined diff --git a/tasks/more.yml b/tasks/more.yml index a869ceb437baf1de8fffc13cf6a96db1bb9e4c70..ef105e1ac29302690d8e8e35fde4e0668f196a57 100644 --- a/tasks/more.yml +++ b/tasks/more.yml @@ -1,14 +1,14 @@ --- # file: roles/commonconnect/tasks/more.yml -- name: "Set facts" +- name: Set facts set_fact: facts: "{{ lookup('file','~/.ansible/hostvars/{{ inventory_name }}') | from_json }}" -- name: "Add Hosts to Hostfile" +- name: Add Hosts to Hostfile lineinfile: - dest: '/etc/hosts' - regexp: '.* {{ item }}$' + dest: /etc/hosts + regexp: .* {{ item }}$ line: '{{ facts[item].static_ipv4 }} {{ item }}' - state: 'present' + state: present with_items: '{{ facts|default([]) }}'