playbook.yml
--- - name: Install Apache and Upload my Web Page hosts: all become: yes vars: source_file: ./website/index.html destin_file: /var/www/html tasks: - name: Cheack and Print Linux Version debug: var=ansible_os_family - block: # === BLOCK REDHAT ==== - name: Install Apache Web Server for RedHat yum: name=httpd state=present - name: Copy index html to Servers copy: src={{ source_file }} dest={{ destin_file }} mode=0555 notify: Restart Apache RedHat - name: Start Apache and Enable it on every boot service: name=httpd state=started enabled=yes when: ansible_os_family == "RedHat" - block: # === BLOCK DEBIAN ==== - name: Install Apache Web Server for Debian apt: name=apache2 state=present - name: Copy index html to Servers copy: src={{ source_file }} dest={{ destin_file }} mode=0555 notify: Restart Apache Debian - name: Start Apache and Enable it on every boot service: name=apache2 state=started enabled=yes when: ansible_os_family == "Debian" handlers: - name: Restart Apache Redhat service: name=httpd state=restarted when: ansible_os_family == "RedHat" - name: Restart Apache Debian service: name=apache2 state=restarted when: ansible_os_family == "Debian" ...