0

I am trying to install php with ansible but can don't know what is going wrong.

this is my ansible file

    ---
- apt_repository:
    repo: "ppa:ondrej/php"
    update_cache: yes

- apt:
    name: "{{ item }}"
    install_recommends: no
    state: present
  with_items:
    - curl
    - php7.2
    - php7.2-apcu-bc
    - php7.2-cli
    - php7.2-common
    - php7.2-curl
    - php7.2-dev
    - php7.2-gd
    - php7.2-mysql
    - php7.2-simplexml
    - php7.2-zip

- name: Turn on short open tags
  ini_file:
    section: "{{ item.section }}"
    dest: /etc/php5/apache2/php.ini
    option: "{{ item.option }}"
    value: "{{ item.value }}"
  with_items:
    - { section: 'PHP', option: 'short_open_tag', value: 'On' }

when I am trying to run it with vagrant, I get this error

failed: [aliuqa] (item=['curl', 'php7.2', 'php7.2-apcu-bc', 'php7.2-cli', 'php7.2-common', 'php7.2-curl', 'php7.2-dev', 'php7.2-gd', 'php7.2-mysql', 'php7.2-simplexml', 'php7.2-zip']) => {"ansible_loop_var": "item", "changed": false, "item": ["curl", "php7.2", "php7.2-apcu-bc", "php7.2-cli", "php7.2-common", "php7.2-curl", "php7.2-dev", "php7.2-gd", "php7.2-mysql", "php7.2-simplexml", "php7.2-zip"], "msg": "No package matching 'php7.2' is available"}

I even tried to install php7.2 manually into my virtualbox but it gives the same package not found related error.

One interesting thing is, when I try to install php5 manually, it works. But for this project, I need php7.2

Versions:

vagrant - 2.0.3

Virtualbox - 6.1.32

ansible - 2.9.1

1 Answers1

1

Have you tried to read the notes of the repository?

Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

7.4 is currently supported. 7.2 isn't. 7.2 is thus not in the repository.

vidarlo
  • 6,654
  • 2
  • 18
  • 31