first commit
This commit is contained in:
parent
a42d394bda
commit
ba90497f07
6
.gitignore
vendored
6
.gitignore
vendored
@ -34,3 +34,9 @@ nosetests.xml
|
|||||||
.mr.developer.cfg
|
.mr.developer.cfg
|
||||||
.project
|
.project
|
||||||
.pydevproject
|
.pydevproject
|
||||||
|
|
||||||
|
ansible.cfg
|
||||||
|
*.pem
|
||||||
|
*.torrent
|
||||||
|
stage
|
||||||
|
murder/
|
||||||
|
16
create_torrent.yml
Normal file
16
create_torrent.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
- name: Create a torrent
|
||||||
|
hosts:
|
||||||
|
- seeder
|
||||||
|
- tracker
|
||||||
|
sudo: yes
|
||||||
|
roles:
|
||||||
|
- murder/create_torrent
|
||||||
|
|
||||||
|
- name: Start seeding
|
||||||
|
hosts: seeder
|
||||||
|
sudo: yes
|
||||||
|
roles:
|
||||||
|
- murder/start_seeding
|
||||||
|
|
8
deploy.yml
Normal file
8
deploy.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
hosts: peer
|
||||||
|
sudo: yes
|
||||||
|
roles:
|
||||||
|
- murder/peer
|
||||||
|
|
10
distribute_files.yml
Normal file
10
distribute_files.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
- name: Upload the support files
|
||||||
|
hosts:
|
||||||
|
- tracker
|
||||||
|
- seeder
|
||||||
|
- peer
|
||||||
|
#sudo: yes
|
||||||
|
roles:
|
||||||
|
- admin/distribute_files
|
||||||
|
|
30
group_vars/all
Normal file
30
group_vars/all
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# The global variable file
|
||||||
|
|
||||||
|
# deploy tag
|
||||||
|
tag: deploy_test1
|
||||||
|
|
||||||
|
# path
|
||||||
|
seeder_files_path: ~/roles
|
||||||
|
destination_path: /tmp
|
||||||
|
|
||||||
|
# path permission
|
||||||
|
destination_owner: root
|
||||||
|
destination_group: root
|
||||||
|
destination_mod: 755
|
||||||
|
|
||||||
|
# default tracker port
|
||||||
|
tracker_port: 8998
|
||||||
|
|
||||||
|
# tar options
|
||||||
|
tar_options: --exclude ".git*" --exclude ".svn*"
|
||||||
|
|
||||||
|
# options
|
||||||
|
no_tag_directory: false
|
||||||
|
unsafe_please_delete: false
|
||||||
|
|
||||||
|
# system path
|
||||||
|
torrent_path: .
|
||||||
|
remote_murder_path: /usr/local/murder
|
||||||
|
ansible_cache_path: /var/cache/ansible
|
||||||
|
default_temp_path: /tmp
|
||||||
|
murder_dist_tgz_file: /tmp/murder_dist_upload.tar.gz
|
19
production
Normal file
19
production
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[tracker]
|
||||||
|
10.0.0.1
|
||||||
|
|
||||||
|
[seeder]
|
||||||
|
10.0.0.1
|
||||||
|
|
||||||
|
[peer:children]
|
||||||
|
seeder
|
||||||
|
web-servers
|
||||||
|
|
||||||
|
|
||||||
|
[web-servers]
|
||||||
|
10.1.1.1
|
||||||
|
10.1.1.2
|
||||||
|
10.1.1.3
|
||||||
|
10.1.1.4
|
||||||
|
10.1.1.[5:19]
|
||||||
|
10.2.1.[100:109] ansible_connection=ssh ansible_ssh_private_key_file=private.pem ansible_ssh_user=root
|
||||||
|
|
11
roles/admin/clone_murder_files/tasks/main.yml
Normal file
11
roles/admin/clone_murder_files/tasks/main.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
- name: clone murder
|
||||||
|
git: repo=https://github.com/lg/murder.git dest=./murder
|
||||||
|
register: clone_status
|
||||||
|
tags: clone_murder_files
|
||||||
|
|
||||||
|
- name: tar -czf
|
||||||
|
shell: tar -czf ./murder_dist.tar.gz -C ./murder/dist/
|
||||||
|
when: clone_status.changed
|
||||||
|
tags: clone_murder_files
|
||||||
|
|
29
roles/admin/distribute_files/tasks/main.yml
Normal file
29
roles/admin/distribute_files/tasks/main.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
- name: mkdir destination_path
|
||||||
|
file: path={{ destination_path }} state=directory owner=root group=root mode=0755
|
||||||
|
tags: distribute_files
|
||||||
|
|
||||||
|
- name: mkdir ansible_cache_path
|
||||||
|
file: path={{ ansible_cache_path }} state=directory owner=root group=root mode=0755
|
||||||
|
tags: distribute_files
|
||||||
|
|
||||||
|
|
||||||
|
- name: upload
|
||||||
|
copy: src={{ murder_dist_tgz_file }} dest={{ ansible_cache_path }}/murder_dist.tar.gz
|
||||||
|
tags: distribute_files
|
||||||
|
register: copy_status
|
||||||
|
|
||||||
|
- name: clean up remote_murder_path
|
||||||
|
shell: |
|
||||||
|
[ $(find {{ remote_murder_path }}/* | wc -l ) -lt 1000 ] &&
|
||||||
|
rm -rf {{ remote_murder_path }}/* ||
|
||||||
|
( echo 'Cowardly refusing to remove files! Check the remote_murder_path.' ; exit 1 )
|
||||||
|
when: copy_status.changed
|
||||||
|
tags: distribute_files
|
||||||
|
|
||||||
|
- name: tar xzf
|
||||||
|
shell: tar xzf {{ ansible_cache_path }}/murder_dist.tar.gz -C "{{ remote_murder_path }}"
|
||||||
|
when: copy_status.changed
|
||||||
|
tags: distribute_files
|
||||||
|
|
||||||
|
|
5
roles/admin/start_tracker/tasks/main.yml
Normal file
5
roles/admin/start_tracker/tasks/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
- name: start tracker
|
||||||
|
shell: SCREENRC=/dev/null SYSSCREENRC=/dev/null screen -dmS murder_tracker python {{ remote_murder_path }}/murder_tracker.py && sleep 0.2
|
||||||
|
tags: start_tracker
|
||||||
|
|
5
roles/admin/stop_all_peering/tasks/main.yml
Normal file
5
roles/admin/stop_all_peering/tasks/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
- name: stop all peering
|
||||||
|
shell: pkill -f "murder_client.py peer"
|
||||||
|
tags: stop_all_peering
|
||||||
|
|
5
roles/admin/stop_all_seeding/tasks/main.yml
Normal file
5
roles/admin/stop_all_seeding/tasks/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
- name: stop all seeding
|
||||||
|
shell: pkill -f "SCREEN.*seeder-"
|
||||||
|
tags: stop_all_seeding
|
||||||
|
|
5
roles/admin/stop_tracker/tasks/main.yml
Normal file
5
roles/admin/stop_tracker/tasks/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
- name: stop tracker
|
||||||
|
shell: pkill -f 'SCREEN.*murder_tracker.py'
|
||||||
|
tags: stop_tracker
|
||||||
|
|
4
roles/murder/clean_temp_files/meta/main.yml
Normal file
4
roles/murder/clean_temp_files/meta/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- { role: murder/common }
|
||||||
|
|
4
roles/murder/clean_temp_files/tasks/main.yml
Normal file
4
roles/murder/clean_temp_files/tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
- name: clean temp files
|
||||||
|
shell: rm -rf "{{ filename }}" "{{ filename }}.torrent"
|
||||||
|
tags: clean_temp_files
|
7
roles/murder/common/tasks/main.yml
Normal file
7
roles/murder/common/tasks/main.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
- name: set tagname to filename
|
||||||
|
set_fact: filename={{ default_temp_path }}/{{ tag }}.tar.gz
|
||||||
|
tags: common
|
||||||
|
|
||||||
|
|
||||||
|
|
3
roles/murder/create_torrent/meta/main.yml
Normal file
3
roles/murder/create_torrent/meta/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- { role: murder/common }
|
21
roles/murder/create_torrent/tasks/main.yml
Normal file
21
roles/murder/create_torrent/tasks/main.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
- name: create tar.gz
|
||||||
|
shell: tar -c -z -C {{ seeder_files_path }}/ -f {{ filename }} {{ tar_options }} .
|
||||||
|
when: node_type == "seeder"
|
||||||
|
tags: create_tgz
|
||||||
|
|
||||||
|
- name: set tracker ip
|
||||||
|
set_fact: tracker_host={{ hostvars[groups['tracker'][0]]['ansible_default_ipv4']['address'] }}
|
||||||
|
when: node_type == "seeder"
|
||||||
|
tags: create_torrent
|
||||||
|
|
||||||
|
- name: create torrent
|
||||||
|
shell: python {{ remote_murder_path }}/murder_make_torrent.py '{{ filename }}' {{ tracker_host }}:{{ tracker_port }} '{{ filename }}.torrent'
|
||||||
|
when: node_type == "seeder"
|
||||||
|
tags: create_torrent
|
||||||
|
|
||||||
|
- name: fetch torrent
|
||||||
|
fetch: src={{ filename }}.torrent dest={{ torrent_path }}/ flat=yes fail_on_missing=yes
|
||||||
|
when: node_type == "seeder"
|
||||||
|
tags: fetch_torrent
|
||||||
|
|
3
roles/murder/peer/meta/main.yml
Normal file
3
roles/murder/peer/meta/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- { role: murder/common }
|
38
roles/murder/peer/tasks/main.yml
Normal file
38
roles/murder/peer/tasks/main.yml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
- name: set destination_path
|
||||||
|
set_fact: destination_path={{ destination_path }}/{{ tag }}
|
||||||
|
when: not no_tag_directory
|
||||||
|
tags: peer
|
||||||
|
|
||||||
|
- name: mkdir destination_path
|
||||||
|
file: path={{ destination_path }} state=directory owner={{ destination_owner }} group={{ destination_group }} mode={{ destination_mod }}
|
||||||
|
tags: peer
|
||||||
|
|
||||||
|
- name: delete destination_path/*
|
||||||
|
shell: rm -rf '{{ destination_path }}a/*'
|
||||||
|
when: unsafe_please_delete
|
||||||
|
tags: peer
|
||||||
|
|
||||||
|
- name: check destination_path/*
|
||||||
|
shell: |
|
||||||
|
(
|
||||||
|
find {{ destination_path }}/* >/dev/null 2>&1 &&
|
||||||
|
echo "destination_path {{ destination_path }} on $HOSTNAME is not empty" &&
|
||||||
|
exit 1
|
||||||
|
) ||
|
||||||
|
exit 0
|
||||||
|
when: not no_tag_directory
|
||||||
|
tags: peer
|
||||||
|
|
||||||
|
- name: upload torrent file
|
||||||
|
copy: src={{ torrent_path }}/{{ filename|basename }}.torrent dest={{ filename }}.torrent
|
||||||
|
tags: peer
|
||||||
|
|
||||||
|
- name: run murder_client.py
|
||||||
|
shell: python {{ remote_murder_path }}/murder_client.py peer '{{ filename }}.torrent' '{{filename}}' {{ ansible_default_ipv4['address'] }}
|
||||||
|
tags: peer
|
||||||
|
|
||||||
|
- name: tar xf
|
||||||
|
shell: tar xf {{ filename }} -C "{{ destination_path }}"
|
||||||
|
tags: peer
|
||||||
|
|
3
roles/murder/start_seeding/meta/main.yml
Normal file
3
roles/murder/start_seeding/meta/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- { role: murder/common }
|
4
roles/murder/start_seeding/tasks/main.yml
Normal file
4
roles/murder/start_seeding/tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
- name: start seeding
|
||||||
|
shell: SCREENRC=/dev/null SYSSCREENRC=/dev/null screen -dmS 'seeder-{{ tag }}' python {{ remote_murder_path }}/murder_client.py seeder '{{ filename }}.torrent' '{{ filename }}' {{ ansible_default_ipv4['address'] }}
|
||||||
|
tags: start_seeding
|
4
roles/murder/stop_peering/meta/main.yml
Normal file
4
roles/murder/stop_peering/meta/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- { role: murder/common }
|
||||||
|
|
4
roles/murder/stop_peering/tasks/main.yml
Normal file
4
roles/murder/stop_peering/tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
- name: stop peering
|
||||||
|
shell: pkill -f "murder_client.py peer.*{{ filename }}"
|
||||||
|
tags: stop_peering
|
4
roles/murder/stop_seeding/meta/main.yml
Normal file
4
roles/murder/stop_seeding/meta/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
dependencies:
|
||||||
|
- { role: murder/common }
|
||||||
|
|
4
roles/murder/stop_seeding/tasks/main.yml
Normal file
4
roles/murder/stop_seeding/tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
- name: stop seeding
|
||||||
|
shell: pkill -f "SCREEN.*seeder-{{ tag }}"
|
||||||
|
tags: stop_seeding
|
6
site.yml
Normal file
6
site.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- distribute_files.yml
|
||||||
|
- create_torrent.yml
|
||||||
|
- deploy.yml
|
||||||
|
- stop_seeder_and_tracker.yml
|
||||||
|
|
7
start_tracker.yml
Normal file
7
start_tracker.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
- name: start tracker
|
||||||
|
hosts: tracker
|
||||||
|
sudo: yes
|
||||||
|
roles:
|
||||||
|
- admin/start_tracker
|
||||||
|
|
7
stop_all.yml
Normal file
7
stop_all.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
- name: Stop all peering
|
||||||
|
hosts: peer
|
||||||
|
sudo: yes
|
||||||
|
roles:
|
||||||
|
- admin/stop_all_peering
|
||||||
|
|
13
stop_seeder_and_tracker.yml
Normal file
13
stop_seeder_and_tracker.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
- name: Stop seeding
|
||||||
|
hosts: seeder
|
||||||
|
sudo: yes
|
||||||
|
roles:
|
||||||
|
- murder/stop_seeding
|
||||||
|
|
||||||
|
- name: Stop tracker
|
||||||
|
hosts: tracker
|
||||||
|
sudo: yes
|
||||||
|
roles:
|
||||||
|
- admin/stop_tracker
|
||||||
|
|
Loading…
Reference in New Issue
Block a user