Browse Source

roles/service: tags and style refactoring

python3
Zolfa 5 years ago
parent
commit
5dfba27c72
Signed by: zolfa GPG Key ID: E1A43B038C4D6616
2 changed files with 29 additions and 25 deletions
  1. +14
    -14
      roles/service/handlers/main.yaml
  2. +15
    -11
      roles/service/tasks/main.yaml

+ 14
- 14
roles/service/handlers/main.yaml View File

@ -1,27 +1,27 @@
---
- name: restart {{ service_name }}
debug: msg="notify restart on all os"
- name: 'restart {{ service_name }}'
debug: msg='notify restart on all os'
changed_when: true
notify:
- restart {{ service_name }} on all distro
- restart {{ service_name }} on openwrt
- 'restart {{ service_name }} on all distro'
- 'restart {{ service_name }} on openwrt'
- name: reload {{ service_name }}
debug: msg="notify reload on all os"
- name: 'reload {{ service_name }}'
debug: msg='notify reload on all os'
changed_when: true
notify:
- reload {{ service_name }} on all distro
- reload {{ service_name }} on openwrt
- 'reload {{ service_name }} on all distro'
- 'reload {{ service_name }} on openwrt'
- block:
- name: restart {{ service_name }} on all distro
- name: 'restart {{ service_name }} on all distro'
service:
name: "{{ service_name }}"
state: restarted
- name: reload {{ service_name }} on all distro
name: '{{ service_name }}'
state: 'restarted'
- name: 'reload {{ service_name }} on all distro'
service:
name: "{{ service_name }}"
state: reloaded
name: '{{ service_name }}'
state: 'reloaded'
when: ansible_distribution != 'openwrt'
- block:


+ 15
- 11
roles/service/tasks/main.yaml View File

@ -1,25 +1,29 @@
---
- block:
- name: install {{ service_name }}
- name: 'install {{ service_name }}'
apt:
pkg: "{{ service_packages }}"
state: present
update_cache: yes
pkg: '{{ service_packages }}'
state: 'present'
update_cache: true
cache_valid_time: 3600
install_recommends: '{{ install_recommends | default("no") }}'
tags:
- 'packages'
- name: start {{ service_name }} at boot
- name: 'start {{ service_name }} at boot'
service:
name: "{{ service_name }}"
enabled: yes
name: '{{ service_name }}'
enabled: true
when: ansible_distribution != 'openwrt'
- block:
- name: install {{ service_name }}
- name: 'install {{ service_name }}'
opkg:
name: "{{ item }}"
state: present
with_items: "{{ service_packages }}"
name: '{{ service_packages | join(" ") }}'
state: 'present'
update_cache: true
tags:
- 'packages'
# remove this in ansible 2.3 (see next comment)
- name: link /etc/init.d/sshd init script to /etc/init.d/ssh


Loading…
Cancel
Save