Skip to content

Commit

Permalink
Auto manages phalcon_package
Browse files Browse the repository at this point in the history
  • Loading branch information
HanXHX committed Aug 31, 2016
1 parent 4846828 commit 3197e0d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Role Variables

- `phalcon_legacy`: (boolean) Uses Phalcon 2. Set false (default) to use latest version.
- `phalcon_version`: (optional) Specify phalcon version. If //null// (default), it installs latest version on repository.
- `phalcon_package` : (string) Package name.
- `phalcon_package` : (string) Package name. If you don't set this variable, this role parses you PHP cli to find the best package (be careful if you want PHP5 and your main php command links to PHP7).

About PHP7
----------
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
phalcon_legacy: false
phalcon_version: null
phalcon_package: 'php5-phalcon'
phalcon_package: null
21 changes: 21 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,24 @@
apt_repository: >
repo="{{ phalcon_apt }}"
state="{{ 'absent' if phalcon_legacy else 'present' }}"
- name: Get PHP
shell: php --version | grep -o '^PHP [[:digit:]]\.[[:digit:]]' | awk '{ print $NF }'
register: phpversion
failed_when: false
changed_when: false

- block:

- name: SET_FACT | Set php5-phalcon
set_fact: phalcon_package='php5-phalcon'
when: phpversion.stdout.find('5') != -1

- name: SET_FACT | Set package from PHP version (manages PHP 7.x)
set_fact: phalcon_package='php{{ phpversion.stdout }}-phalcon'
when: phpversion.stdout.find('5') == -1

when: >
phalcon_package is none and
not phpversion.failed
1 change: 0 additions & 1 deletion tasks/legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
apt_repository: >
repo="{{ phalcon_legacy_apt }}"
state="{{ 'present' if phalcon_legacy else 'absent' }}"
1 change: 0 additions & 1 deletion tests/group_vars/php5
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
phalcon_package: 'php5-phalcon'
test_packages:
- php5-cli
1 change: 0 additions & 1 deletion tests/group_vars/php7
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
phalcon_package: 'php7.0-phalcon'
test_packages:
- php7.0-cli

0 comments on commit 3197e0d

Please # to comment.