1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-27 01:08:37 +00:00
dockerfiles/aria2/playbook.yml

140 lines
3.0 KiB
YAML
Raw Normal View History

2016-03-19 10:58:42 +00:00
---
- name: deploy aria2/yaaw to raspbian
hosts: pi
vars:
ansible_become: yes
tasks:
2016-03-22 11:45:44 +00:00
- name: ensure softwares are installed
2016-03-19 10:58:42 +00:00
apt:
2016-03-22 11:45:44 +00:00
name: '{{item}}'
2016-03-19 10:58:42 +00:00
state: present
2016-03-22 11:45:44 +00:00
with_items:
- aria2
- nginx
- samba
2016-03-19 10:58:42 +00:00
- name: create aria2 service file
copy:
content: |
[Unit]
Description=High speed download utility
After=network.target
2016-03-22 11:45:44 +00:00
2016-03-19 10:58:42 +00:00
[Service]
User=pi
2016-03-22 11:45:44 +00:00
Environment=DIR=/home/pi/share
2016-03-19 10:58:42 +00: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 11:45:44 +00:00
notify:
- reload systemd
- restart aria2
2016-03-19 10:58:42 +00:00
2016-03-22 11:45:44 +00:00
- name: ensure services are running
2016-03-19 10:58:42 +00:00
service:
2016-03-22 11:45:44 +00:00
name: '{{item}}'
2016-03-19 10:58:42 +00:00
state: started
enabled: yes
2016-03-22 11:45:44 +00:00
with_items:
- aria2
- nginx
- smbd
2016-03-19 10:58:42 +00: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 11:45:44 +00:00
location /share {
2016-03-19 10:58:42 +00:00
autoindex on;
2016-03-22 11:45:44 +00:00
alias /home/pi/share;
2016-03-19 10:58:42 +00: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 17:06:51 +00:00
- block:
2016-04-07 00:14:41 +00:00
- name: update samba config for global
2016-04-06 17:06:51 +00:00
ini_file:
dest: /etc/samba/smb.conf
2016-04-07 00:14:41 +00: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 17:06:51 +00:00
notify:
- restart samba
2016-04-07 00:14:41 +00:00
- name: update samba config for share
2016-04-06 17:06:51 +00: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 11:45:44 +00:00
2016-03-19 10:58:42 +00:00
handlers:
2016-03-22 11:45:44 +00:00
- name: reload systemd
command: systemctl daemon-reload
- name: restart aria2
service:
name: aria2
state: restarted
2016-03-19 10:58:42 +00:00
- name: restart nginx
service:
name: nginx
state: restarted
2016-03-22 11:45:44 +00:00
- name: restart samba
service:
name: smbd
state: restarted