1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-27 02:09:06 +02:00
dockerfiles/aria2/playbook.yml

140 lines
3.0 KiB
YAML
Raw Normal View History

2016-03-19 12:58:42 +02:00
---
- name: deploy aria2/yaaw to raspbian
hosts: pi
vars:
ansible_become: yes
tasks:
2016-03-22 13:45:44 +02:00
- name: ensure softwares are installed
2016-03-19 12:58:42 +02:00
apt:
2016-03-22 13:45:44 +02:00
name: '{{item}}'
2016-03-19 12:58:42 +02:00
state: present
2016-03-22 13:45:44 +02:00
with_items:
- aria2
- nginx
- samba
2016-03-19 12:58:42 +02:00
- name: create aria2 service file
copy:
content: |
[Unit]
Description=High speed download utility
After=network.target
2016-03-22 13:45:44 +02:00
2016-03-19 12:58:42 +02:00
[Service]
User=pi
2016-03-22 13:45:44 +02:00
Environment=DIR=/home/pi/share
2016-03-19 12:58:42 +02:00
ExecStartPre=/bin/mkdir -p ${DIR}
ExecStart=/usr/bin/aria2c --enable-rpc \
--rpc-listen-all=true \
--rpc-allow-origin-all \
--dir ${DIR}
Restart=on-failure
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/aria2.service
2016-03-22 13:45:44 +02:00
notify:
- reload systemd
- restart aria2
2016-03-19 12:58:42 +02:00
2016-03-22 13:45:44 +02:00
- name: ensure services are running
2016-03-19 12:58:42 +02:00
service:
2016-03-22 13:45:44 +02:00
name: '{{item}}'
2016-03-19 12:58:42 +02:00
state: started
enabled: yes
2016-03-22 13:45:44 +02:00
with_items:
- aria2
- nginx
- smbd
2016-03-19 12:58:42 +02:00
- name: create nginx yaaw site
copy:
content: |
server {
listen 80;
server_name _;
location / {
index index.html;
root /var/www/yaaw-master;
}
2016-03-22 13:45:44 +02:00
location /share {
2016-03-19 12:58:42 +02:00
autoindex on;
2016-03-22 13:45:44 +02:00
alias /home/pi/share;
2016-03-19 12:58:42 +02:00
}
}
dest: /etc/nginx/sites-available/yaaw
- name: download yaaw archive
unarchive:
src: https://github.com/binux/yaaw/archive/master.zip
dest: /var/www
copy: no
- name: disable nginx default site
file:
dest: /etc/nginx/sites-enabled/default
state: absent
- name: enable nginx yaaw site
file:
src: /etc/nginx/sites-available/yaaw
dest: /etc/nginx/sites-enabled/yaaw
state: link
notify:
- restart nginx
changed_when: yes
2016-04-06 19:06:51 +02:00
- block:
2016-04-07 02:14:41 +02:00
- name: update samba config for global
2016-04-06 19:06:51 +02:00
ini_file:
dest: /etc/samba/smb.conf
2016-04-07 02:14:41 +02:00
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- {section: global, option: guest account, value: pi}
- {section: global, option: netbios name, value: pi}
2016-04-06 19:06:51 +02:00
notify:
- restart samba
2016-04-07 02:14:41 +02:00
- name: update samba config for share
2016-04-06 19:06:51 +02:00
blockinfile:
dest: /etc/samba/smb.conf
insertafter: EOF
content: |
[share]
path = /home/pi/share
browseable = yes
read only = no
guest ok = yes
notify:
- restart samba
2016-03-22 13:45:44 +02:00
2016-03-19 12:58:42 +02:00
handlers:
2016-03-22 13:45:44 +02:00
- name: reload systemd
command: systemctl daemon-reload
- name: restart aria2
service:
name: aria2
state: restarted
2016-03-19 12:58:42 +02:00
- name: restart nginx
service:
name: nginx
state: restarted
2016-03-22 13:45:44 +02:00
- name: restart samba
service:
name: smbd
state: restarted