ansible yaml

Yaml code posted by M
created at 31 Jul 03:59, updated at 31 Jul 04:09

Edit | Back
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
---
- hosts: all
  tasks:
  - name: ensure nginx is installed
    action: apt pkg=nginx state=present
  - name: ensure nginx is running
    action: service name=nginx state=started

- hosts: puppy
  vars:
    baby: puppy
  tasks:
  - name: ensure puppy group is created
    action: group name=puppy state=present
  - name: ensure puppy user is created
    action: user name=puppy state=present group=puppy
  - name: ensure puppy.jpg is present
    action: copy src=/root/puppy.jpg dest=/usr/share/nginx/www/puppy.jpg
              owner=puppy group=puppy mode=664
  - name: ensure index.html template is installed
    action: template src=/root/index.j2
              dest=/usr/share/nginx/www/index.html

- hosts: kitty
  vars:
    baby: kitty
  tasks:
  - name: ensure kitty group is created
    action: group name=kitty state=present
  - name: ensure kitty user is created
    action: user name=kitty state=present group=kitty
  - name: ensure kitty.jpg is present
    action: copy src=/root/kitty.jpg dest=/usr/share/nginx/www/kitty.jpg
              owner=kitty group=kitty mode=664
  - name: ensure index.html template is installed
    action: template src=/root/index.j2 dest=/usr/share/nginx/www/index.html
1.22 KB in 3 ms with coderay