|
32 | 32 | recurse: yes |
33 | 33 | when: simplesamlphp_exists.stat.exists and simplesamlphp_exists.stat.isdir |
34 | 34 |
|
35 | | -- name: Get simplesamlphp tarball |
36 | | - become: yes |
37 | | - become_user: "meza-ansible" |
38 | | - get_url: |
39 | | - url: "https://github.com/simplesamlphp/simplesamlphp/releases/download/v{{ simplesamlphp_version }}/simplesamlphp-{{ simplesamlphp_version }}.tar.gz" |
40 | | - dest: "{{ m_home }}/meza-ansible/" |
41 | | - register: new_simplesamlphp_archive |
42 | | - |
43 | | -- name: Remove simplesamlphp directory if new version available |
| 35 | +- name: "Create {{ m_simplesamlphp_path }} if it doesn't exist" |
44 | 36 | file: |
45 | 37 | path: "{{ m_simplesamlphp_path }}" |
46 | | - state: absent |
47 | | - when: new_simplesamlphp_archive.changed |
| 38 | + state: directory |
| 39 | + owner: "{{ m_simplesamlphp_owner }}" |
| 40 | + group: "{{ m_simplesamlphp_group }}" |
| 41 | + mode: "{{ m_simplesamlphp_mode }}" |
48 | 42 |
|
49 | | -# Do this check again now in case the above command removed the directory, but something went |
50 | | -# wrong and it was never created (script crashed). Without this check the deploy could be put |
51 | | -# in a state where it might never recreate SimpleSamlPhp |
52 | | -- name: "Check if {{ m_simplesamlphp_path }} exists again" |
| 43 | +- name: Check if SimpleSAMLphp is already installed with correct version |
53 | 44 | stat: |
54 | | - path: "{{ m_simplesamlphp_path }}" |
55 | | - register: simplesamlphp_exists2 |
56 | | - |
57 | | -- name: "Create empty directory for {{ m_simplesamlphp_path }} if installing new version" |
| 45 | + path: "{{ m_simplesamlphp_path }}/composer.json" |
| 46 | + register: simplesamlphp_composer |
| 47 | + |
| 48 | +- name: Check current SimpleSAMLphp version if installed |
| 49 | + shell: | |
| 50 | + if [ -f "{{ m_simplesamlphp_path }}/composer.lock" ]; then |
| 51 | + grep -A 3 '"name": "simplesamlphp/simplesamlphp"' {{ m_simplesamlphp_path }}/composer.lock | grep '"version"' | head -1 | cut -d'"' -f4 |
| 52 | + else |
| 53 | + echo "not_installed" |
| 54 | + fi |
| 55 | + register: current_ssp_version |
| 56 | + changed_when: false |
| 57 | + when: simplesamlphp_composer.stat.exists |
| 58 | + |
| 59 | +- name: Install SimpleSAMLphp {{ simplesamlphp_version }} via Composer (fresh install) |
| 60 | + become: yes |
| 61 | + become_user: "{{ m_simplesamlphp_owner }}" |
| 62 | + composer: |
| 63 | + command: create-project |
| 64 | + arguments: simplesamlphp/simplesamlphp:{{ simplesamlphp_version }} . |
| 65 | + working_dir: "{{ m_simplesamlphp_path }}" |
| 66 | + no_dev: no |
| 67 | + when: not simplesamlphp_composer.stat.exists |
| 68 | + |
| 69 | +- name: Update SimpleSAMLphp to {{ simplesamlphp_version }} via Composer |
| 70 | + become: yes |
| 71 | + become_user: "{{ m_simplesamlphp_owner }}" |
| 72 | + composer: |
| 73 | + command: require |
| 74 | + arguments: simplesamlphp/simplesamlphp:{{ simplesamlphp_version }} |
| 75 | + working_dir: "{{ m_simplesamlphp_path }}" |
| 76 | + no_dev: no |
| 77 | + when: |
| 78 | + - simplesamlphp_composer.stat.exists |
| 79 | + - current_ssp_version.stdout != simplesamlphp_version |
| 80 | + - current_ssp_version.stdout != "v{{ simplesamlphp_version }}" |
| 81 | + |
| 82 | +- name: Ensure required SimpleSAMLphp directories exist |
58 | 83 | file: |
59 | | - path: "{{ m_simplesamlphp_path }}" |
| 84 | + path: "{{ m_simplesamlphp_path }}/{{ item }}" |
60 | 85 | state: directory |
61 | 86 | owner: "{{ m_simplesamlphp_owner }}" |
62 | 87 | group: "{{ m_simplesamlphp_group }}" |
63 | | - mode: "{{ m_simplesamlphp_mode }}" |
64 | | - when: not simplesamlphp_exists2.stat.exists |
| 88 | + mode: "0755" |
| 89 | + loop: |
| 90 | + - config |
| 91 | + - metadata |
| 92 | + - log |
| 93 | + - cache |
| 94 | + - cert |
| 95 | + |
| 96 | +- name: Ensure log directory is writable |
| 97 | + file: |
| 98 | + path: "{{ m_simplesamlphp_path }}/log" |
| 99 | + state: directory |
| 100 | + owner: "{{ m_simplesamlphp_owner }}" |
| 101 | + group: "{{ m_simplesamlphp_group }}" |
| 102 | + mode: "0775" |
65 | 103 |
|
66 | | -- name: Unarchive simplesamlphp tarball if new |
67 | | - become: yes |
68 | | - unarchive: |
69 | | - src: "{{ m_home }}/meza-ansible/simplesamlphp-{{ simplesamlphp_version }}.tar.gz" |
70 | | - dest: "{{ m_simplesamlphp_path }}" |
| 104 | +- name: Ensure cache directory is writable |
| 105 | + file: |
| 106 | + path: "{{ m_simplesamlphp_path }}/cache" |
| 107 | + state: directory |
71 | 108 | owner: "{{ m_simplesamlphp_owner }}" |
72 | 109 | group: "{{ m_simplesamlphp_group }}" |
73 | | - mode: "{{ m_simplesamlphp_mode }}" |
74 | | - remote_src: yes |
75 | | - extra_opts: |
76 | | - - "--strip-components=1" |
77 | | - when: not simplesamlphp_exists2.stat.exists or new_simplesamlphp_archive.changed |
| 110 | + mode: "0775" |
78 | 111 |
|
79 | 112 | - name: Ensure Extension:PluggableAuth installed |
80 | 113 | become: yes |
|
0 commit comments