additional course material RH294
Student User
2020-02-19 26d781da63ad0368921d6a0eb1f5efcb9bc479d1
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 a webserver and start the service
  hosts: server
  become: true
  remote_user: devops
  force_handlers: true
  vars:
    - installstate: present
  tasks:
    - name: Install httpd
      package:
        name: httpd
        state: '{{ installstate }}'
    - name: create index.html
      copy:
        dest: /var/www/html/index.html
        content: 'Welcome to {{ ansible_fqdn }}!'
        mode: 0644
    - name: start httpd
      service:
        name: httpd
        state: started
        enabled: true
    - name: 'retrieve content from port 80'
      uri:
        url: "http://localhost:80/index.html"
        return_content: false
      ignore_errors: true
    - name: change listen port to 8080
      lineinfile:
        dest: /etc/httpd/conf/httpd.conf
        regexp: '^Listen 80$'
        line: 'Listen 8080'
        state: present
      notify:
        - restart httpd
    - name: retrieve content from port 8080
      uri:
        url: "http://localhost:8080/index.html"
        return_content: false
      
        
  handlers:
    - name: restart httpd
      service:
        name: httpd
        state: restarted
 
- name: verify
  hosts: server
  tasks:
    - name: retrieve content from port 80
      uri:
        url: "http://localhost:80/index.html"
        return_content: false
      ignore_errors: true
    - name: retrieve content from port 8080
      uri:
        url: "http://localhost:8080/index.html"
        return_content: false