Skip to content

Commit

Permalink
Add AtoM2.7 and BS5 support (#117)
Browse files Browse the repository at this point in the history
* Add AtoM2.7 and BS5 support

This commit adds support to AtoM 2.7 on CentOS/RedHat using the REMI
repository for PHP.

The bootstrap 5 support has been added for Ubuntu/CentOS/RedHat.
Basicasilly it uses latest nodejs version 14 and changes the
dependencies.

* Use php_version instead atom_php_version in conditionals

* Fix atom_php_version available options

* Use deps-rh-php-74.yml instead of deps-rh-74.yml

* Fix bad task names including 'AtoM version >= 7.4'

* Improve php_rh_centos_path conditionals

* Update README.md
  • Loading branch information
mamedin authored Dec 8, 2022
1 parent 3f6c2a1 commit 3bb0fbb
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 27 deletions.
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,42 @@ Please feel free to add support for other platforms, pull requests accepted!

Please visit our [deploy-pub](https://github.com/artefactual/deploy-pub/tree/master/playbooks/atom) repository for a real usage example.

## Notes on OS, AtoM version and php version

This role allows to install AtoM on CentOS 7 and Ubuntu 14.04, 16:04, 18.04 and
20.04. But not all the AtoM versions can be installed in all OS.

|AtoM version| PHP version | CentOS support | Ubuntu support | ElasticSearch version | MySQL version |
|------------|----------------|----------------|----------------|-----------------------|---------------|
| AtoM 2.3 |5.5, 5.6 and 7.0| CentOS 7 | 14.04 and 16.04| >=1.3,<2.0 | >=5.1,<6.0 |
| AtoM 2.4 |5.5, 5.6 and 7.0| CentOS 7 | 14.04 and 16.04| >=1.3,<2.0 | >=5.1,<6.0 |
| AtoM 2.5 | 7.0 and 7.2 | CentOS 7 | 16.04 and 18.04| >=5.0,<6.0 | >=5.1,<6.0 |
| AtoM 2.6 | 7.2 and 7.3 | CentOS 7 | 18.04 | >=5.0,<6.0 | >=8.0 |
| AtoM 2.7 | 7.4 | CentOS 7 | 20.04 | >=5.0,<6.0 | >=8.0 |

The next table explains the valid `atom_php_version` values that you can use
depending on the AtoM version and Linux Distro. It is very important to take
into account the default value (last column), because if you need a different
php version you must set the `atom_php_version` variable on ansible `host_vars`
or `group_vars` files to the desired version.

|Linux Distro| AtoM 2.3 | AtoM 2.4 | AtoM 2.5 | AtoM 2.6 | AtoM 2.7 | Default |
|------------|----------|----------|----------|----------|----------|----------|
| CentOS 7 | 70 | 70 | 70,71,72 | 72,73 | 74 | 72 |
|Ubuntu 14.04| 5 | 5 | | | | 5 |
|Ubuntu 16.04| 7.0 | 7.0 | 7.0 | | | 7.0 |
|Ubuntu 18.04| | | 7.2 | 7.2 | | 7.2 |
|Ubuntu 20.04| | | | | 7.4 | 7.4 |

From the table above, you can see the Linux distro you need depending on
the AtoM version. For instance, AtoM 2.7 can only be installed on CentOS 7 or
Ubuntu 20.04.

## Notes on dependencies

- AtoM <=2.4, Binder 0.8: Elasticsearch>=1.3,<2.0
- Atom 2.5, Binder 0.9: Elasticsearch>=5.3,<6.x
- AtoM <=2.4, Binder 0.8: Elasticsearch>=1.3,<2.0; MySQL>5.1,<6.0
- Atom 2.5, Binder 0.9: Elasticsearch>=5.3,<6.x; MySQL>5.1,<6.0
- AtoM >= 2.6: Elasticsearch>=5.3,<6.x; MySQL>=8.0

## Overriding default templates

Expand Down
14 changes: 9 additions & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ atom_private_symlink: "no"
atom_csrf_protection: "no"

#
# Choose php version to use
# - For RH/Centos 70,71,72 and 73 are available. Default is 72
# - Ubuntu 14.04 uses php 5, 16.04 7.0 and 18.04 7.2
#
# atom_php_version: 72
# Choose php version to use.
# NOTE: Ubuntu >= 16.04 uses a php version that includes a point
# - For RH/Centos 70,71,72,73 and 74 are available. Default is 72
# - For Ubuntu 14.04: 5
# - For Ubuntu 16.04: 7.0
# - For Ubuntu 18.04: 7.2
# - For Ubuntu 20.04: 7.4
#
#atom_php_version: 72
#

#
Expand Down
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
become_user: "{{ atom_user }}"
environment:
- "{{ atom_pool_php_envs }}"
- PATH: "{{ ansible_env.PATH }}:/opt/rh/rh-php{{ php_version }}/root/bin/"
- PATH: "{{ ansible_env.PATH }}:{{ php_rh_centos_path | default('')}}"

- name: "Restart smbd"
service:
Expand Down
89 changes: 86 additions & 3 deletions tasks/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
- not atom_compile_all_themes|bool # Don't compile themes when they are alreay compiled
when: ansible_os_family == "Debian"

- name: "Build AtoM themes (CentOS/RH)"
- name: "Build AtoM themes (CentOS/RH and php version < 7.4)"
block:
- name: "Build all AtoM themes (CentOS/RH)"
shell: "scl enable rh-nodejs6 make || make"
Expand All @@ -59,14 +59,79 @@
become: "no"
when:
- not atom_compile_all_themes|bool # Don't compile themes when they are alreay compiled
when: ansible_os_family == "RedHat"
when:
- ansible_os_family == "RedHat"
- php_version|int < 74

- name: "Build AtoM themes (CentOS/RH and php version >= 7.4)"
block:
- name: "Build all AtoM themes (CentOS/RH)"
shell: "make"
args:
chdir: "{{ item }}"
with_items: "{{ theme_makefiles.stdout_lines }}"
become: "no"
when:
- atom_compile_all_themes|bool
- name: "Build selected AtoM themes (CentOS/RH)"
shell: "{{ item.build_cmd }}"
args:
chdir: "{{ item.path }}"
with_items: "{{ atom_themes }}"
become: "no"
when:
- not atom_compile_all_themes|bool # Don't compile themes when they are alreay compiled
when:
- ansible_os_family == "RedHat"
- php_version|int >= 74

#
# Bootstrap 5 support
#

- name: "Prepare npm to be used with bootstrap5 themes"
block:
- name: "Update npm to latest version of its release"
command: "npm install -g npm@latest"
- name: "Get AtoM user home directory"
become_user: "{{ atom_user }}"
become: "yes"
shell: >
getent passwd {{ atom_user }} | awk -F: '{ print $6 }'
changed_when: false
register: __atom_user_home_directory
- name: "Create npm directories on {{ atom_user }} home dir"
become: "yes"
file:
path: "{{ __atom_user_home_directory.stdout }}/{{ item }}"
state: "directory"
owner: "{{ atom_user }}"
group: "{{ atom_group }}"
loop:
- ".config"
- ".npm"
- name: "Clean cache, install and build with npm on AtoM site directory"
become: "yes"
become_user: "{{ atom_user }}"
command: "{{ item }}"
args:
chdir: "{{ atom_path }}/{{ atom_extra_path }}"
environment:
CYPRESS_INSTALL_BINARY: 0
loop:
- "npm cache clean --force"
- "npm install"
- "npm run build"
when:
# Removing "." for Ubuntu php_version, for instance: 7.4
- php_version|replace('.','')|int >= 74

#
# DRMC/Binder
#


- name: "Binder npm build tasks (CentOS/RedHat)"
- name: "Binder npm build tasks (CentOS/RedHat and php version < 7.4)"
block:
- name: "Install npm local dependencies (SCL)"
command: "scl enable rh-nodejs6 'npm update' || npm update"
Expand All @@ -80,6 +145,24 @@
when:
- "atom_drmc is defined and atom_drmc|bool"
- ansible_os_family == "RedHat"
- php_version|int < 74
become: "no"

- name: "Binder npm build tasks (CentOS/RedHat and php version >= 7.4)"
block:
- name: "Install npm local dependencies"
npm:
path: "{{ atom_drmc_path }}"
state: "latest"
# using --force option to ignore Error compiling ../../arDominionPlugin/css/main.less
- name: "Build DRMC"
command: "grunt build --force"
args:
chdir: "{{ atom_drmc_path }}"
when:
- "atom_drmc is defined and atom_drmc|bool"
- ansible_os_family == "RedHat"
- php_version|int >= 74
become: "no"

- name: "Binder npm build tasks (Ubuntu)"
Expand Down
66 changes: 66 additions & 0 deletions tasks/deps-rh-php-74.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---

- name: "Install epel repo"
yum:
name: "epel-release"
state: "installed"

- name: "Enable epel repo"
ini_file:
path: /etc/yum.repos.d/epel.repo
section: epel
option: enabled
value: 1

- name: "Import Remi GPG key (php version >= 7.4)"
rpm_key:
key: "https://rpms.remirepo.net/RPM-GPG-KEY-remi2022"
state: present

- name: "Install Remi Repo (php version >= 7.4)"
yum:
name: "https://rpms.remirepo.net/enterprise/remi-release-7.rpm"
state: "installed"

- name: "Import nodesource GPG key (php version >= 7.4)"
rpm_key:
key: "https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL"
state: present

- name: "Install nodesource Repo (php version >= 7.4)"
yum:
name: "https://rpm.nodesource.com/pub_14.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm"
state: "installed"

- name: "Add rpmfusion free repo (for ffmpeg)"
command: 'yum localinstall -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm'
args:
creates: "/etc/yum.repos.d/rpmfusion-free-updates.repo"

- name: "Install AtoM dependencies"
yum:
name:
- "ImageMagick" # ↓ AtoM dependencies
- "ghostscript" #
- "poppler-utils" #
- "ffmpeg" #
- "git" # ↓ Build dependencies
- "make" #
- "gcc" #
- "java-1.8.0-openjdk-headless" # needed by FOP
- "Judy-devel" # needed by memprof
state: "latest"

- name: "Install nodejs build dependency (php version >= 7.4)"
yum:
name:
- "nodejs"
state: "latest"

- name: "Install npm global dependencies (also required during the build)"
npm:
name: "{{ item }}"
global: "yes"
with_items:
- "grunt-cli"
- "less@<4.0.0"
14 changes: 13 additions & 1 deletion tasks/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
update_cache: "yes"
when: "ansible_distribution_version is version('14.04', '<=')"

- name: "Add nodesource repo for nodejs (Ubuntu >=20.04)"
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
state: present
when: "ansible_distribution_version is version('20.04', '>=')"

- name: "Add nodejs 14.x ppa for apt repo (Ubuntu >=20.04)"
apt_repository:
repo: "deb https://deb.nodesource.com/node_14.x focal main"
update_cache: "yes"
when: "ansible_distribution_version is version('20.04', '>=')"

- name: "Install AtoM dependencies (Ubuntu <= Xenial/16.04)"
apt:
pkg:
Expand Down Expand Up @@ -62,7 +74,7 @@
- "poppler-utils" #
- "ffmpeg" #
- "git" # ↓ Build dependencies
- "npm" #
- "nodejs" #
- "make" #
- "openjdk-8-jre-headless" # Needed by FOP
- "libjudy-dev" # Needed by memprof
Expand Down
2 changes: 1 addition & 1 deletion tasks/flush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# become_user: "{{ atom_user }}"
# environment:
# - "{{ atom_pool_php_envs }}"
# - PATH: {{ ansible_env.PATH }}:/opt/rh/rh-php{{ php_version }}/root/bin/
# - PATH: {{ ansible_env.PATH }}:{{ php_rh_centos_path }}
# when: "atom_flush_data is defined and atom_flush_data|bool"


Expand Down
28 changes: 23 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
- "atom-deps"
when:
- ansible_os_family == "RedHat"
- php_version|int < 74

- include: "deps-rh-php-74.yml"
tags:
- "atom-deps"
when:
- ansible_os_family == "RedHat"
- php_version|int >= 74

- include: "php.yml"
tags:
Expand All @@ -29,22 +37,32 @@

- include: "php-rh.yml"
environment:
- PATH: "{{ ansible_env.PATH }}:/opt/rh/rh-php{{ php_version }}/root/bin/"
- PATH: "{{ ansible_env.PATH }}:{{ php_rh_centos_path }}"
tags:
- "atom-php"
when:
- ansible_os_family == "RedHat"
- php_version|int < 74

- include: "php-rh-74.yml"
environment:
- PATH: "{{ ansible_env.PATH }}:{{ php_rh_centos_path }}"
tags:
- "atom-php"
when:
- ansible_os_family == "RedHat"
- php_version|int >= 74

- include: "php-composer.yml"
environment:
- PATH: "{{ ansible_env.PATH }}:/opt/rh/rh-php{{ php_version }}/root/bin/"
- PATH: "{{ ansible_env.PATH }}:{{ php_rh_centos_path | default('') }}"
tags:
- "atom-php"
- "atom-php-composer"

- include: "fop.yml"
environment:
- PATH: "{{ ansible_env.PATH }}:/opt/rh/rh-php{{ php_version }}/root/bin/"
- PATH: "{{ ansible_env.PATH }}:{{ php_rh_centos_path | default('')}}"
tags:
- "fop"

Expand Down Expand Up @@ -105,7 +123,7 @@
become_user: "{{ atom_user }}"
environment:
- "{{ atom_pool_php_envs }}"
- PATH: "{{ ansible_env.PATH }}:/opt/rh/rh-php{{ php_version }}/root/bin/"
- PATH: "{{ ansible_env.PATH }}:{{ php_rh_centos_path | default('') }}"
when: >
(uninitialized is defined and uninitialized|bool) or
(atom_flush_data is defined and atom_flush_data|bool)
Expand All @@ -116,7 +134,7 @@
become_user: "{{ atom_user }}"
environment:
- "{{ atom_pool_php_envs }}"
- PATH: "{{ ansible_env.PATH }}:/opt/rh/rh-php{{ php_version }}/root/bin/"
- PATH: "{{ ansible_env.PATH }}:{{ php_rh_centos_path | default('') }}"
tags:
- "atom-plugins"

Expand Down
4 changes: 2 additions & 2 deletions tasks/php-pool-cfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
- name: "Remove default www pool"
file:
state: "absent"
path: "/etc/opt/rh/rh-php{{ php_version }}/php-fpm.d/www.conf"
path: "{{ php_rh_centos_etc_path }}/php-fpm.d/www.conf"
- name: "Install pool configuration file"
template:
src: "etc/php/7.0/fpm/pool.d/atom.conf"
dest: "/etc/opt/rh/rh-php{{ php_version }}/php-fpm.d/{{ atom_pool_name }}.conf"
dest: "{{ php_rh_centos_etc_path }}/php-fpm.d/{{ atom_pool_name }}.conf"
notify:
- "Restart PHP service"
when:
Expand Down
Loading

0 comments on commit 3bb0fbb

Please sign in to comment.