Skip to content

Commit 1f62593

Browse files
committed
replace service with systemd_service
1 parent 126889e commit 1f62593

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
lines changed

content/en/docs/03/_index.en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ Complete the next steps using Ansible ad hoc commands:
119119
{{% details title="Solution Task 6" %}}
120120
```bash
121121
ansible web -i hosts -b -m ansible.builtin.dnf -a "name=httpd state=installed"
122-
ansible web -i hosts -b -m ansible.builtin.service -a "name=httpd state=started enabled=yes"
122+
ansible web -i hosts -b -m ansible.builtin.systemd_service -a "name=httpd state=started enabled=yes"
123123
```
124124

125125
Reverting the changes made on the remote hosts:
126126

127127
```bash
128-
ansible web -i hosts -b -m service -a "name=httpd state=stopped enabled=no"
128+
ansible web -i hosts -b -m systemd_service -a "name=httpd state=stopped enabled=no"
129129
ansible web -i hosts -b -m ansible.builtin.dnf -a "name=httpd state=absent"
130130
```
131131
{{% /details %}}

content/en/docs/04/01/_index.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Remember `loop:` or `with_items:`
1919
Delete the 2 tasks "start and enable \[httpd,firewalld\]". Add a new task with the following content:
2020
```yaml
2121
- name: start and enable services
22-
ansible.builtin.service:
22+
ansible.builtin.systemd_service:
2323
name: "{{ item }}"
2424
state: started
2525
enabled: true

content/en/docs/04/03/_index.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ ansible web -b -m copy -a "content='bli bla blup' dest=/etc/httpd/conf/httpd.con
196196
Now fix your apache config. You could use the backup of the file created in the previous ad-hoc command.
197197

198198
```bash
199-
ansible web -b -m ansible.builtin.service -a "name=httpd state=restarted"
199+
ansible web -b -m ansible.builtin.systemd_service -a "name=httpd state=restarted"
200200
```
201201
{{% /details %}}
202202

content/en/docs/04/_index.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ Below is a possible solution for your playbook:
3434
name: httpd
3535
state: installed
3636
- name: start and enable httpd
37-
ansible.builtin.service:
37+
ansible.builtin.systemd_service:
3838
name: httpd
3939
state: started
4040
enabled: true
4141
- name: start and enable firewalld
42-
ansible.builtin.service:
42+
ansible.builtin.systemd_service:
4343
name: firewalld
4444
state: started
4545
enabled: true
4646
- name: open firewall for http
4747
firewalld:
48-
ansible.builtin.service: http
48+
ansible.builtin.systemd_service: http
4949
state: enabled
5050
permanent: true
5151
immediate: true

content/en/docs/05/_index.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ $ cat roles/httpd/tasks/main.yml
4242
- firewalld
4343
state: installed
4444
- name: start services
45-
ansible.builtin.service:
45+
ansible.builtin.systemd_service:
4646
name: "{{ item }}"
4747
state: started
4848
enabled: true

content/en/docs/10/_index.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,18 @@ $ cat site.yml
113113
name: httpd
114114
state: installed
115115
- name: start and enable httpd
116-
ansible.builtin.service:
116+
ansible.builtin.systemd_service:
117117
name: httpd
118118
state: started
119119
enabled: true
120120
- name: start and enable firewalld
121-
ansible.builtin.service:
121+
ansible.builtin.systemd_service:
122122
name: firewalld
123123
state: started
124124
enabled: true
125125
- name: open firewall for http
126126
firewalld:
127-
ansible.builtin.service: http
127+
ansible.builtin.systemd_service: http
128128
state: enabled
129129
permanent: true
130130
immediate: true

content/en/docs/11/01/_index.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ cat webserver.yml
7979
- firewalld
8080
state: installed
8181
- name: start and enable httpd
82-
ansible.builtin.service:
82+
ansible.builtin.systemd_service:
8383
name: httpd
8484
state: started
8585
enabled: true
@@ -90,7 +90,7 @@ cat webserver.yml
9090
owner: root
9191
group: root
9292
- name: start and enable firewalld
93-
ansible.builtin.service:
93+
ansible.builtin.systemd_service:
9494
name: firewalld
9595
state: started
9696
enabled: true
@@ -164,7 +164,7 @@ cat webserver_rulebook.yml
164164
```bash
165165
ansible-rulebook --rulebook webserver_rulebook.yml -i inventory/hosts --verbose
166166

167-
ansible node1 -i inventory/hosts -b -m service -a "name=httpd state=stopped"
167+
ansible node1 -i inventory/hosts -b -m ansible.builtin.systemd_service -a "name=httpd state=stopped"
168168
```
169169
{{% /details %}}
170170

content/en/docs/11/02/_index.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cat debug_event_rulebook.yml
3737
var: event
3838
```
3939
```bash
40-
ansible node1 -i inventory/hosts -b -m service -a "name=httpd state=stopped"
40+
ansible node1 -i inventory/hosts -b -m ansible.builtin.systemd_service -a "name=httpd state=stopped"
4141
```
4242
```bash
4343
ansible-rulebook --rulebook debug_event_rulebook.yml -i inventory/hosts -vv

slides/ansible-techlab/puzzle-demo.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ pull (Puppet way) vs push (ansible way) --> push braucht weder daemon noch sonst
370370
- Transporters:
371371
`ssh`, `local`, `winrm`, `docker`,...
372372
- Modules:
373-
`file`, `template`, `firewalld`, `service`, `yum`,...
373+
`file`, `template`, `firewalld`, `systemd_service`, `yum`,...
374374
- Dynamic inventories:
375375
`vmware`, `cloudscale`, `foreman`, `azure`, `aws`,...
376376

@@ -615,14 +615,14 @@ right:
615615
### quoting of variables or spacing
616616
wrong:
617617
```yaml
618-
- ansible.builtin.service:
618+
- ansible.builtin.systemd_service:
619619
name: {{ item }}
620620
state: started
621621
loop: "{{my_services}}"
622622
```
623623
right:
624624
```yaml
625-
- ansible.builtin.service:
625+
- ansible.builtin.systemd_service:
626626
name: "{{ item }}"
627627
state: started
628628
loop: "{{ my_services }}"
@@ -801,7 +801,7 @@ A bit more complex:
801801
name: mariadb
802802
state: installed
803803
- name: start mariadb
804-
ansible.builtin.service:
804+
ansible.builtin.systemd_service:
805805
name: mariadb
806806
state: started
807807
```
@@ -931,7 +931,7 @@ Don't name your Variables after Magic Variables
931931
## Bonus Level: Loops!
932932
```yaml
933933
- name: start and enable two services
934-
ansible.builtin.service:
934+
ansible.builtin.systemd_service:
935935
name: "{{ item }}"
936936
state: started
937937
enabled: true
@@ -1284,7 +1284,7 @@ Example (no roles yet):
12841284
- ansible.builtin.dnf:
12851285
name: httpd
12861286
state: installed
1287-
- service:
1287+
- ansible.builtin.systemd_service:
12881288
name: httpd
12891289
state: started
12901290
```
@@ -1389,7 +1389,7 @@ Example Playbook:
13891389
notify: restart sshd
13901390
handlers:
13911391
- name: restart sshd
1392-
ansible.builtin.service:
1392+
ansible.builtin.systemd_service:
13931393
name: sshd
13941394
state: restarted
13951395
```
@@ -1410,7 +1410,7 @@ Example Playbook:
14101410
notify: restart sshd
14111411
handlers:
14121412
- name: sshd restart
1413-
ansible.builtin.service:
1413+
ansible.builtin.systemd_service:
14141414
name: sshd
14151415
state: restarted
14161416
listen: restart sshd
@@ -1443,11 +1443,11 @@ Only second handler will run when a task notifies `restart web services`
14431443
```yaml
14441444
handlers:
14451445
- name: restart web services
1446-
ansible.builtin.service:
1446+
ansible.builtin.systemd_service:
14471447
name: memcached
14481448
state: restarted
14491449
- name: restart web services
1450-
ansible.builtin.service:
1450+
ansible.builtin.systemd_service:
14511451
name: apache
14521452
state: restarted
14531453
```

0 commit comments

Comments
 (0)