From 3a78eb20541413e8c20f2b3584ae9be554e1c836 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 19 Jun 2020 12:00:07 +0200 Subject: [PATCH] Update to 2020-06-19 12:00 --- roles/common/meta/main.yml | 3 +-- roles/patrix/defaults/main.yml | 8 +++++++ roles/patrix/tasks/install_Debian.yml | 2 ++ roles/patrix/tasks/install_RedHat.yml | 1 + roles/patrix/tasks/main.yml | 39 +++-------------------------------- 5 files changed, 15 insertions(+), 38 deletions(-) diff --git a/roles/common/meta/main.yml b/roles/common/meta/main.yml index 88a0538..42c19e5 100644 --- a/roles/common/meta/main.yml +++ b/roles/common/meta/main.yml @@ -22,8 +22,7 @@ dependencies: when: - patrix_enabled | default(True) - patrix_server is defined - - patrix_user is defined - - patrix_pass is defined + - (patrix_user is defined and patrix_pass is defined) or patrix_token is defined - role: postfix when: system_postfix | default(True) - role: timers diff --git a/roles/patrix/defaults/main.yml b/roles/patrix/defaults/main.yml index 0b1bf8d..a0905b6 100644 --- a/roles/patrix/defaults/main.yml +++ b/roles/patrix/defaults/main.yml @@ -1,8 +1,16 @@ --- # patrix_server: +# +# +# Auth can be done either with login / pass # patrix_user: # patrix_pass: +# +# Or with an existing token +# +# patrix_token: +# # patrix_room: ... diff --git a/roles/patrix/tasks/install_Debian.yml b/roles/patrix/tasks/install_Debian.yml index 98f6516..8aa4d0d 100644 --- a/roles/patrix/tasks/install_Debian.yml +++ b/roles/patrix/tasks/install_Debian.yml @@ -12,6 +12,7 @@ - libjson-perl - libterm-readkey-perl - libhash-merge-simple-perl + tags: patrix - name: Install patrix get_url: @@ -20,4 +21,5 @@ mode: 0755 environment: - https_proxy: "{{ system_proxy | default('') }}" + tags: patrix diff --git a/roles/patrix/tasks/install_RedHat.yml b/roles/patrix/tasks/install_RedHat.yml index 76c3a54..829066f 100644 --- a/roles/patrix/tasks/install_RedHat.yml +++ b/roles/patrix/tasks/install_RedHat.yml @@ -2,3 +2,4 @@ - name: Install patrix yum: name=patrix + tags: patrix diff --git a/roles/patrix/tasks/main.yml b/roles/patrix/tasks/main.yml index 555f119..2ba8e1b 100644 --- a/roles/patrix/tasks/main.yml +++ b/roles/patrix/tasks/main.yml @@ -2,41 +2,8 @@ - include_tasks: install_{{ ansible_os_family }}.yml -- name: Check if patrixrc exists - stat: path=/root/.patrixrc - register: patrix_rc - -- name: Create patrixrc file - copy: - dest: /root/.patrixrc - content: | - [default] - server=_server_ - access_token=_access_token_ - room=_room_ - when: not patrix_rc.stat.exists - -- name: Get an access token - command: patrix --get-access-token --server={{ patrix_server }} --user={{ patrix_user }} --password={{ patrix_pass }} - register: patrix_token - environment: - - https_proxy: "{{ system_proxy | default('') }}" - when: not patrix_rc.stat.exists - -- name: Configure patrix - ini_file: - path: /root/.patrixrc - section: default - option: "{{ item.option }}" - value: "{{ item.value }}" - no_log: True - with_items: - - option: server - value: "{{ patrix_server }}" - - option: access_token - value: "{{ patrix_token.stdout }}" - - option: room - value: "{{ patrix_room }}" - when: not patrix_rc.stat.exists and patrix_token is defined +- name: Deploy patrix config for root user + template: src=patrixrc.j2 dest=/root/.patrixrc mode='600' + tags: patrix ...