|
--- - hosts: '{{ hosts }}'
gather_facts: no
vars:
host_links: |
{% set l = [] %}
{% for channel in channels|sort(case_sensitive=True, attribute='link') %}
{% set _ = l.append(links[channel.link].ip+' '+channel.link) %}
{% endfor %}
{{ l | unique }}
host_channels: |
{% set c = [] %}
{% for channel in channels|sort(case_sensitive=True, attribute='name') %}
{% set s = '#' if channel.status == 'disable' else '' %}
{% for type in channel.type|sort %}
{% set p = '|1' if channel.picture == type else '' %}
{% set _ = c.append(s+channel.link+':'+links[channel.link].port|string()+'|wxcenter|'+channel.name+'|'+type+'|60'+p) %}
{% endfor %}
{% endfor %}
{{ c }}
tasks:
- name: update /etc/hosts
template: src=hosts.j2 dest=/etc/hosts owner=root group=root mode=0644
notify:
- restart svscan
- name: update /opt/script/channels.list
template: src=channels.list.j2 dest=/opt/script/channels.list owner=root group=root mode=0644
notify:
- delete channel file
- restart svscan
handlers:
- name: delete channel file
shell: /bin/find /opt/online01/{m3u8,muxer} -name "{{ item.name }}"* | /usr/bin/xargs /bin/rm -rf
when: item.status == 'disable'
with_items: "{{ channels }}"
- name: restart svscan
command: /sbin/initctl restart svscan |
|
|