Skip to content

Commit 689c96d

Browse files
committed
Upgrade Composer, use Composer to install SimpleSAMLphp, update Apache config templates
1 parent f1c373d commit 689c96d

4 files changed

Lines changed: 71 additions & 38 deletions

File tree

src/roles/apache-php/templates/httpd.conf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ Listen 8080
448448

449449
{% if saml_secret is defined -%}
450450
# Use SimpleSamlPhp to handle authentication
451-
Alias /simplesaml {{ m_simplesamlphp_path }}/www
452-
<Directory {{ m_simplesamlphp_path }}/www>
451+
Alias /simplesaml {{ m_simplesamlphp_path }}/public
452+
<Directory {{ m_simplesamlphp_path }}/public>
453453
Require all granted
454454
Options All -Indexes
455455
</Directory>

src/roles/apache-php/templates/php-fpm-httpd.conf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ Listen 8080
448448

449449
{% if saml_secret is defined -%}
450450
# Use SimpleSamlPhp to handle authentication
451-
Alias /simplesaml {{ m_simplesamlphp_path }}/www
452-
<Directory {{ m_simplesamlphp_path }}/www>
451+
Alias /simplesaml {{ m_simplesamlphp_path }}/public
452+
<Directory {{ m_simplesamlphp_path }}/public>
453453
Require all granted
454454
Options All -Indexes
455455
</Directory>

src/roles/composer/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
when: not composer_bin.stat.exists
2929

3030
# Enforce composer 1.x per #1272. Per #1273 we should make Meza support Composer 2.x.
31-
- name: Set Composer to version 2.3.6
31+
- name: Set Composer to version 2.8.12
3232
shell: >
33-
{{ php_executable }} {{ composer_path }} self-update 2.3.6
33+
{{ php_executable }} {{ composer_path }} self-update 2.8.12
3434
register: composer_update
3535
changed_when: "'Updating to version' in composer_update.stdout"
3636
when: composer_keep_updated

src/roles/saml/tasks/main.yml

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,49 +32,82 @@
3232
recurse: yes
3333
when: simplesamlphp_exists.stat.exists and simplesamlphp_exists.stat.isdir
3434

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"
4436
file:
4537
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 }}"
4842

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
5344
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
5883
file:
59-
path: "{{ m_simplesamlphp_path }}"
84+
path: "{{ m_simplesamlphp_path }}/{{ item }}"
6085
state: directory
6186
owner: "{{ m_simplesamlphp_owner }}"
6287
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"
65103

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
71108
owner: "{{ m_simplesamlphp_owner }}"
72109
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"
78111

79112
- name: Ensure Extension:PluggableAuth installed
80113
become: yes

0 commit comments

Comments
 (0)