From ab716ebe2a15d6dc1ea3ba9a94aaa4878a7420f2 Mon Sep 17 00:00:00 2001 From: Chu-Siang Lai Date: Thu, 22 Jun 2017 20:57:45 +0800 Subject: [PATCH 1/2] add `apt_php_official_repo` varible for switch official repo #17 --- defaults/main.yml | 6 ++++++ tasks/use-apt.yml | 45 +++++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index f75575a..0f38a4b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -39,6 +39,12 @@ debian_php7_apt_repo: "http://packages.dotdeb.org" debian_php7_apt_key: "https://www.dotdeb.org/dotdeb.gpg" ubuntu_php7_ppa_repo: "ppa:ondrej/php" +# A switch for use official apt repository. +# +# true: use the official repository. +# false: use the third-party repository. +apt_php_official_repo: false + apt_php_version: "7.0" #apt_php_version: "7.1" diff --git a/tasks/use-apt.yml b/tasks/use-apt.yml index 75ad2d4..e4cd8f4 100644 --- a/tasks/use-apt.yml +++ b/tasks/use-apt.yml @@ -2,30 +2,35 @@ --- # before install. -- name: install requires package for use apt module +- name: Install requires package for apt module become: true apt: name=python-apt state=present -- name: Add third-party repository for Debian - become: true - apt_repository: > - repo="deb {{ debian_php7_apt_repo }} {{ ansible_distribution_release }} all" - state=present - when: - - ansible_distribution|lower == "debian" - - ansible_distribution_major_version < "9" +- block: -- name: Add apt key for Debian - become: true - apt_key: url={{ debian_php7_apt_key }} state=present - when: - - ansible_distribution|lower == "debian" - - ansible_distribution_major_version < "9" + - name: Add third-party repository on Debian + become: true + apt_repository: > + repo="deb {{ debian_php7_apt_repo }} {{ ansible_distribution_release }} all" + state=present + when: + - ansible_distribution|lower == "debian" + - ansible_distribution_major_version < "9" + + - name: Add apt key on Debian + become: true + apt_key: url={{ debian_php7_apt_key }} state=present + when: + - ansible_distribution|lower == "debian" + - ansible_distribution_major_version < "9" + + - name: Add third-party repository on Ubuntu + become: true + apt_repository: repo={{ ubuntu_php7_ppa_repo }} + when: + - ansible_distribution|lower == "ubuntu" -- name: Add third-party repository for Ubuntu - become: true - apt_repository: repo={{ ubuntu_php7_ppa_repo }} - when: ansible_distribution|lower == "ubuntu" + when: apt_php_official_repo == false # Update apt cache. - name: Update apt cache @@ -33,7 +38,7 @@ apt: update_cache=true # Install PHP7 packages. -- name: Install PHP Packages +- name: Install php packages become: true apt: name={{ item }} state=present with_nested: "{{ apt_php_packages }}" From 7a00d5f39a9327a33e520e6d4a6695698a11d790 Mon Sep 17 00:00:00 2001 From: Chu-Siang Lai Date: Thu, 22 Jun 2017 21:58:40 +0800 Subject: [PATCH 2/2] write note for add new varible of apt_php_official_repo --- README.md | 11 ++++++++++- defaults/main.yml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2586ccd..a134be4 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,12 @@ debian_php7_apt_repo: "http://packages.dotdeb.org" debian_php7_apt_key: "https://www.dotdeb.org/dotdeb.gpg" ubuntu_php7_ppa_repo: "ppa:ondrej/php" +# A switch for use official apt repository. +# +# true: use the official repository. +# false: use the third-party repository. +apt_php_official_repo: false + apt_php_version: "7.0" #apt_php_version: "7.1" @@ -130,6 +136,8 @@ centos_nginx_fastcgi_server: "unix:{{ centos_php_fastcgi_listen }}" * `/etc/php.ini` * Socket: `/run/php-fpm/www.sock` +1. We add `apt_php_official_repo `variable for enable or disable the third-party repository (after v1.3.6). + ## Dependencies None. @@ -142,7 +150,7 @@ None. roles: - { role: chusiang.php7 } -## Docker Container +## Docker Containers This repository contains Dockerized [Ansible](https://github.com/ansible/ansible), published to the public [Docker Hub](https://hub.docker.com/) via **automated build** mechanism. @@ -170,3 +178,4 @@ MIT License (2015 - 2017). See the [LICENSE file](LICENSE) for details. 1. [itcraftsmanpl (Arkadiusz Kondas)](http://itcraftsman.pl/) 1. [chusiang (Chu-Siang Lai)](http://note.drx.tw) + diff --git a/defaults/main.yml b/defaults/main.yml index 0f38a4b..b602d1e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -39,7 +39,7 @@ debian_php7_apt_repo: "http://packages.dotdeb.org" debian_php7_apt_key: "https://www.dotdeb.org/dotdeb.gpg" ubuntu_php7_ppa_repo: "ppa:ondrej/php" -# A switch for use official apt repository. +# A switch for enable or disable the third-party repository. # # true: use the official repository. # false: use the third-party repository.