Ansible

---
- hosts: all
  become: true
  vars:
    doc_root: /var/www/example
  tasks:
    - name: Update apt
      apt: update_cache=yes

    - name: Install Apache
      apt: name=apache2 state=latest

    - name: Create custom document root
      file: path={{ doc_root }} state=directory owner=www-data group=www-data

    - name: Set up HTML file
      copy: src=index.html dest={{ doc_root }}/index.html owner=www-data group=www-data mode=0644

    - name: Set up Apache virtual host file
      template: src=vhost.tpl dest=/etc/apache2/sites-available/000-default.conf
      notify: restart apache

    - name: return motd to registered var
      command: cat /etc/motd
      register: mymotd

  handlers:
    - name: restart apache
      service: name=apache2 state=restarted
---
- hosts: '{{ target }}'
  become: true
  vars:
    doc_root: /var/www/example
  tasks:
  - name: Test de copie de fichier
    copy:
        src: /tmp/test.conf
        dest: /home/user/test.conf
         #owner: root
         #group: root
         #mode: 0644
         backup: yes
  - name: Check if PHP is installed
        register: php_installed
        command: php -v
        ignore_errors: true

become: true
vars_files:
  - /etc/ansible/group_vars/web-dev/vault
- lineinfile:
    path: /etc/group
    regexp: '^userx'
    line: 'userx:x:999:'
  async: 1
  poll: 0
  when: id_userx.rc != 999

- lineinfile:
    path: /etc/passwd
    regexp: '^userx'
    line: 'userx:x:999:999:User X:/home/userx:/bin/bash'
  async: 1
  poll: 0
  when: id_userx.rc != 999