index.2j
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="index.css"> <title> Просто страничка для тестов</title> </head> <body> <p> hello MEN </p> <p> страница generate </p> </tr> <p> print owner: {{ owner }} </p> <p> print hostname: {{ ansible_hostname }} </p> <p> print fqdn: {{ ansible_fqdn }} </p> <p> print os: {{ ansible_os_family }} </p> <p> IP address: {{ ansible_default_ipv4.address }} </p> </body> </html> |
playbook.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
--- - name: Install Apache and Upload my Web Page hosts: all become: yes vars: source_folder: ./website destin_folder: /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: 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: Start Apache and Enable it on every boot service: name=apache2 state=started enabled=yes when: ansible_os_family == "Debian" - name: Generate INDEX.HTML file template: src={{ source_folder }}/index.j2 dest={{ destin_folder }}/index.html mode=555 notify: - Restart Apache RedHat - Restart Apache Debian - name: Copy folder to web Servers copy: src={{ source_folder }}/{{ item }} dest={{ destin_folder }} mode=0555 loop: - "file0.txt" - "file1.txt" - "file2.txt" notify: - Restart Apache RedHat - Restart Apache 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" ... |