In order to install php7 seven I need to enable remi-php71 repo using following command:
yum-config-manager --enable remi-php71
How can I do it in an ansible task?
I had the same need (but for 5.6). Following the advice in the discussion here I used the following:
- name: enable remi-php56
ini_file:
dest: /etc/yum.repos.d/remi.repo
section: remi-php56
option: enabled
value: 1
The advantage over using yum_repository
is I don't have to maintain the definition - I install the remi repos from the RPM he provides. The advantage over the shell
variant (which should probably be command
anyway) is I don't need to run commands and I don't need the yum utils installed just for this
You can do this to issue that specific shell command:
- name: enable remi-php71
shell: yum-config-manager --enable remi-php71
Although it is probably better to declare the yum repo itself via something like:
- name: Add remi-php71
yum_repository:
name: remi-php71
description: Remi's PHP 7.1 RPM repository for Enterprise Linux $releasever - $basearch
mirrorlist: http://rpms.remirepo.net/enterprise/$releasever/php71/mirror
enabled: yes
gpgcheck: 1
gpgkey: http://rpms.remirepo.net/RPM-GPG-KEY-remi
Docs here and here.
You can also enable the repository only during the installation process:
- name: Install PHP packages
yum:
name:
- php
- php-cli
- php-common
- php-devel
- php-fpm
- php-gd
- php-ldap
- etc...
state: latest
enablerepo: "remi,remi-php71"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With