use become

This commit is contained in:
Robert Kaussow 2018-07-06 23:18:11 +02:00
parent c6f2c9c54f
commit 1f36ad2c49
3 changed files with 43 additions and 37 deletions

View File

@ -1,5 +1,5 @@
--- ---
- name: restart iptables - name: Restart iptables
shell: sleep 2 && systemctl restart iptables shell: sleep 2 && systemctl restart iptables
async: 1 async: 1
poll: 0 poll: 0

View File

@ -1,5 +1,7 @@
--- ---
- name: Set custom iptables rules - name: Setup iptables
block:
- name: Set custom iptables rules
iptables_raw: iptables_raw:
name: 'iptables_custom_rules_{{ item.name }}' name: 'iptables_custom_rules_{{ item.name }}'
rules: '{{ item.rules }}' rules: '{{ item.rules }}'
@ -11,7 +13,7 @@
label: "{{item.name}}" label: "{{item.name}}"
tags: iptables tags: iptables
- name: Set default iptables head rules - name: Set default iptables head rules
iptables_raw: iptables_raw:
name: iptables_default_head name: iptables_default_head
weight: 10 weight: 10
@ -20,7 +22,7 @@
rules: '{{ iptables_default_head }}' rules: '{{ iptables_default_head }}'
tags: iptables tags: iptables
- name: Set default iptables tail rules - name: Set default iptables tail rules
iptables_raw: iptables_raw:
name: iptables_default_tail name: iptables_default_tail
weight: 99 weight: 99
@ -28,3 +30,4 @@
state: '{{ (iptables_default_tail != "" ) | ternary("present", "absent") }}' state: '{{ (iptables_default_tail != "" ) | ternary("present", "absent") }}'
rules: '{{ iptables_default_tail }}' rules: '{{ iptables_default_tail }}'
tags: iptables tags: iptables
become: True

View File

@ -1,11 +1,14 @@
--- ---
- name: Install package - name: Install iptables
block:
- name: Install packages
package: package:
name: '{{ iptables_package }}' name: "{{ iptables_package }}"
state: latest state: latest
- name: Enable and start service - name: Enable and start service
service: service:
name: iptables name: iptables
enabled: True enabled: True
state: started state: started
become: True