Tutorial: Hello Ansible on iMinds Virtual Wall - SolutionΒΆ

 1- name: Configure server
 2  hosts: server
 3  sudo: True
 4  vars: 
 5    iperf_server_log: /var/www/iperflogs/iperf-server.log
 6  tasks:
 7   - name: install apache2
 8     apt: name=apache2 update_cache=yes
 9   - name: install iperf
10     apt: name=iperf update_cache=yes
11   - name: /usr/sbin/a2enmod status
12     command: /usr/sbin/a2enmod status
13   - name: check /etc/apache2/mods-enabled/status.conf file is absent
14     file:
15        path: /etc/apache2/mods-enabled/status.conf
16        state: absent
17   - name: copy website/index.html into /var/www
18     synchronize: src=website/index.html dest=/var/www
19   - name: copy the website/graphics directory into /var/www
20     synchronize: src=website/graphics dest=/var/www
21   - name: rm -rf /var/www/html
22     file: path=/var/www/html state=absent
23   - name: Make simlink to webfiles
24     file:
25        dest: /var/www/html
26        src: /var/www/
27        state: link
28   - name: Make sure /etc/apache2/conf.d/extendedstatus file contains "ExtendedStatus On"
29     lineinfile: 
30        line: 'ExtendedStatus On' 
31        dest: /etc/apache2/conf.d/extendedstatus 
32        create: yes 
33        state: present   
34   - name: Make sure /etc/apache2/sites-available/000-default.conf contains Location information
35     blockinfile: 
36        block: |
37            <Location /server-status>
38               SetHandler server-status
39               Allow from all
40            </Location> 
41        dest: /etc/apache2/sites-available/000-default.conf  
42        create: yes 
43        state: present 
44        insertafter: EOF 
45        backup: yes
46   - name: restart apache2 service
47     service: name=apache2 state=restarted
48   - name: create directory for iperf logs in /var/www/iperflogs with permissions of 755
49     file: 
50        dest: /var/www/iperflogs
51        state: directory
52        mode: 0755
53   - name: start server
54     command: /usr/bin/sudo /bin/bash -c "iperf -s -i 10 &> {{ iperf_server_log }}" 
55     async: 86400
56     poll: 0