---
- name: Add PHP 7.1 PPA
  apt_repository:
    repo: "ppa:ondrej/php"
    update_cache: yes

- name: Install PHP 7.1
  apt:
    name: "{{ item }}"
    state: present
    force: yes
  with_items:
  - php7.1-cli
  - php7.1-common
  - php7.1-curl
  - php7.1-dev
  - php7.1-fpm
  - php7.1-gd
  - php7.1-mbstring
  - php7.1-mcrypt
  - php7.1-mysql
  - php7.1-opcache
  - php7.1-xml
  - php7.1-xmlrpc
  - php7.1-zip

- name: Start php7.1-fpm service
  service:
    name: php7.1-fpm
    state: started
    enabled: true

- name: Create socket directory
  file:
    path: /var/run/php7.1-fpm/
    state: directory

- name: PHP configuration file
  template:
    src: php.ini.j2
    dest: /etc/php/7.1/fpm/php.ini
  notify: reload php-fpm

---
- name: Add PHP 7.1 PPA
  apt_repository:
    repo: "ppa:ondrej/php"
    update_cache: yes

- name: Install PHP 7.1
  apt:
    name: "{{ item }}"
    state: present
    force: yes
  with_items:
  - php7.1-cli
  - php7.1-common
  - php7.1-curl
  - php7.1-dev
  - php7.1-fpm
  - php7.1-gd
  - php7.1-mbstring
  - php7.1-mcrypt
  - php7.1-mysql
  - php7.1-opcache
  - php7.1-xml
  - php7.1-xmlrpc
  - php7.1-zip

- name: Start php7.1-fpm service
  service:
    name: php7.1-fpm
    state: started
    enabled: true

- name: PHP configuration file
  template:
    src: php.ini.j2
    dest: /etc/php/7.1/fpm/php.ini
  notify: reload php-fpm

Remove creation of unused socket directory
Remove creation of unused socket directory

The php7.1-fpm socket is created at /var/run so no need for this directory to be created
