finalyse jdownloader role
This commit is contained in:
commit
12cbe9e010
30
README.md
Normal file
30
README.md
Normal file
@ -0,0 +1,30 @@
|
||||
JDownloader
|
||||
=========
|
||||
Headless install of JDwowloader
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
21
defaults/main.yml
Normal file
21
defaults/main.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
# defaults file for JDowloader
|
||||
|
||||
JD_packageName: jdownloader2
|
||||
JD_Username: jdownloader2
|
||||
JD_HomeDirectory: "/var/lib/{{JD_Username}}"
|
||||
JD_myJDemail: toto@toto.fr
|
||||
JD_myJDPassword: XXXXX
|
||||
JD_defaultdownloadfolder: "{{JD_Username}}/download"
|
||||
JD_service: true
|
||||
JD_my_JDconfig_options:
|
||||
- option: password
|
||||
value: "{{JD_myJDPassword}}"
|
||||
- option: email
|
||||
value: "{{JD_myJDemail}}"
|
||||
- option: devicename
|
||||
value: "{{JD_Username}}@{{ inventory_hostname }}"
|
||||
|
||||
JD_general_config_options:
|
||||
- option: defaultdownloadfolder
|
||||
value: "{{JD_defaultdownloadfolder}}"
|
19
files/JDgeneralconfig.json
Normal file
19
files/JDgeneralconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"closedwithrunningdownloads" : false,
|
||||
"maxsimultanedownloadsperhost" : 1,
|
||||
"delaywritemode" : "AUTO",
|
||||
"maxdownloadsperhostenabled" : false,
|
||||
"dupemanagerenabled" : true,
|
||||
"savelinkgrabberlistenabled" : true,
|
||||
"forcemirrordetectioncaseinsensitive" : true,
|
||||
"preferbouncycastlefortls" : false,
|
||||
"convertrelativepathsjdroot" : true,
|
||||
"keepxoldlists" : 5,
|
||||
"autostartdownloadoption" : "ONLY_IF_EXIT_WITH_RUNNING_DOWNLOADS",
|
||||
"useavailableaccounts" : true,
|
||||
"maxsimultanedownloads" : 3,
|
||||
"defaultdownloadfolder" : "/var/lib/jdownloader2/Downloads",
|
||||
"downloadspeedlimitrememberedenabled" : true,
|
||||
"downloadspeedlimitenabled" : false,
|
||||
"downloadspeedlimit" : 51200
|
||||
}
|
6
files/myJDdefaultconfig.json
Normal file
6
files/myJDdefaultconfig.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"autoconnectenabledv2" : true,
|
||||
"password" : "",
|
||||
"email" : "",
|
||||
"devicename" : ""
|
||||
}
|
16
handlers/main.yml
Normal file
16
handlers/main.yml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
# handlers file for JDowloader
|
||||
|
||||
|
||||
- name: Reload systemd
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
become: yes
|
||||
|
||||
|
||||
- name: restart JDownloader service
|
||||
systemd:
|
||||
name: "JDownloader.service" # not required. Name of the service. When using in a chroot environment you always need to specify the full name i.e. (crond.service).
|
||||
state: restarted # not required. choices: reloaded;restarted;started;stopped. C(started)/C(stopped) are idempotent actions that will not run commands unless necessary. C(restarted) will always bounce the service. C(reloaded) will always reload.
|
||||
enabled: true
|
||||
become: yes
|
53
meta/main.yml
Normal file
53
meta/main.yml
Normal file
@ -0,0 +1,53 @@
|
||||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.9
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
# platforms:
|
||||
# - name: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 25
|
||||
# - name: SomePlatform
|
||||
# versions:
|
||||
# - all
|
||||
# - 1.0
|
||||
# - 7
|
||||
# - 99.99
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
|
120
tasks/main.yml
Normal file
120
tasks/main.yml
Normal file
@ -0,0 +1,120 @@
|
||||
---
|
||||
# tasks file for JDowloader
|
||||
|
||||
- name: install aur JDownloader
|
||||
aur:
|
||||
name: "{{ JD_packageName }}"
|
||||
state: present
|
||||
|
||||
- name: check if default java is set
|
||||
shell: archlinux-java status|grep "(default)"
|
||||
register: is_java_set
|
||||
failed_when:
|
||||
- is_java_set.rc > 1
|
||||
changed_when:
|
||||
- is_java_set.rc == 1
|
||||
|
||||
- name: set default java
|
||||
become: yes
|
||||
shell: "archlinux-java set $(archlinux-java status|grep java|sort -h|head -n1)"
|
||||
when: is_java_set.changed
|
||||
|
||||
- name: create dedicated user
|
||||
become: yes
|
||||
user:
|
||||
name: "{{ JD_Username }}" # required. Name of the user to create, remove or modify.
|
||||
force: no # not required. This only affects C(state=absent), it forces removal of the user and associated directories on supported platforms. The behavior is the same as C(userdel --force), check the man page for C(userdel) on your system for details and support.
|
||||
create_home: yes # not required. Unless set to C(no), a home directory will be made for the user when the account is created or if the home directory does not exist.,Changed from C(createhome) to C(create_home) in version 2.5.
|
||||
home: "{{ JD_HomeDirectory }}" # not required. Optionally set the user's home directory.
|
||||
shell: /bin/sh # not required. Optionally set the user's shell.,On macOS, before version 2.5, the default shell for non-system users was q. Since 2.5, the default shell for non-system users on macOS is /bin/bash.
|
||||
state: present # not required. choices: absent;present. Whether the account should exist or not, taking action if the state is different from what is stated.
|
||||
when: JD_service ==true
|
||||
|
||||
- name: install JDownloader
|
||||
become: yes
|
||||
become_user: "{{ JD_Username }}"
|
||||
shell:
|
||||
cmd: JDownloaderHeadless
|
||||
chdir: "{{ JD_HomeDirectory }}"
|
||||
creates: "{{ JD_HomeDirectory }}/.jd"
|
||||
|
||||
|
||||
|
||||
- name: check if my JDownloader config file is present
|
||||
become: yes
|
||||
become_user: "{{ JD_Username }}"
|
||||
stat:
|
||||
path: "{{JD_HomeDirectory}}/.jd/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json" # required. The full path of the file/object to get the facts of.
|
||||
register: testmyJDconfigfile
|
||||
|
||||
|
||||
- name: copy default myJDownloader config file
|
||||
become: yes
|
||||
become_user: "{{ JD_Username }}"
|
||||
copy:
|
||||
dest: "{{JD_HomeDirectory}}/.jd/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json" # required. Remote absolute path where the file should be copied to. If I(src) is a directory, this must be a directory too. If I(dest) is a nonexistent path and if either I(dest) ends with "/" or I(src) is a directory, I(dest) is created. If I(src) and I(dest) are files, the parent directory of I(dest) isn't created: the task fails if it doesn't already exist.
|
||||
src: myJDdefaultconfig.json # not required. Local path to a file to copy to the remote server; can be absolute or relative. If path is a directory, it is copied recursively. In this case, if path ends with "/", only inside contents of that directory are copied to destination. Otherwise, if it does not end with "/", the directory itself with all contents is copied. This behavior is similar to Rsync.
|
||||
when: testmyJDconfigfile.stat.exists == false
|
||||
|
||||
- name: set myJDowloader config
|
||||
become: yes
|
||||
become_user: "{{ JD_Username }}"
|
||||
lineinfile:
|
||||
path: "{{JD_HomeDirectory}}/.jd/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json"
|
||||
regexp: '^\s*"{{ item.option }}"'
|
||||
line: ' "{{ item.option }}" : "{{ item.value }}",'
|
||||
with_items: '{{ JD_my_JDconfig_options }}'
|
||||
when: JD_my_JDconfig_options is defined
|
||||
|
||||
- name: check if JDownloader general config file is present
|
||||
become: yes
|
||||
become_user: "{{ JD_Username }}"
|
||||
stat:
|
||||
path: "{{JD_HomeDirectory}}/.jd/cfg/org.jdownloader.settings.GeneralSettings.json"
|
||||
register: tesJDgeneralconfigfile
|
||||
|
||||
|
||||
- name: copy default myJDownloader config file
|
||||
become: yes
|
||||
become_user: "{{ JD_Username }}"
|
||||
copy:
|
||||
dest: "{{JD_HomeDirectory}}/.jd/cfg/org.jdownloader.settings.GeneralSettings.json"
|
||||
src: JDgeneralconfig.json # not required. Local path to a file to copy to the remote server; can be absolute or relative. If path is a directory, it is copied recursively. In this case, if path ends with "/", only inside contents of that directory are copied to destination. Otherwise, if it does not end with "/", the directory itself with all contents is copied. This behavior is similar to Rsync.
|
||||
when: tesJDgeneralconfigfile.stat.exists == false
|
||||
|
||||
|
||||
|
||||
- name: set JDownloader general config
|
||||
become: yes
|
||||
become_user: "{{ JD_Username }}"
|
||||
|
||||
lineinfile:
|
||||
path: "{{JD_HomeDirectory}}/.jd/cfg/org.jdownloader.settings.GeneralSettings.json"
|
||||
regexp: '^\s*"{{ item.option }}"'
|
||||
line: ' "{{ item.option }}" : "{{ item.value }}",'
|
||||
with_items: '{{ JD_general_config_options }}'
|
||||
when: JD_general_config_options is defined
|
||||
|
||||
- name: apply JDowloader daemon template
|
||||
template:
|
||||
dest: "/etc/systemd/system/JDownloader.service" # required. Location to render the template to on the remote machine.
|
||||
src: "JDownloader.service.j2" # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
|
||||
become: yes
|
||||
notify:
|
||||
- Reload systemd
|
||||
- restart JDownloader service
|
||||
when: JD_service ==true
|
||||
|
||||
- name: Reload systemd
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
become: yes
|
||||
|
||||
|
||||
- name: enable JDownloader service
|
||||
systemd:
|
||||
name: "JDownloader.service" # not required. Name of the service. When using in a chroot environment you always need to specify the full name i.e. (crond.service).
|
||||
enabled: true
|
||||
state: started
|
||||
become: yes
|
||||
when: JD_service ==true
|
15
templates/JDownloader.service.j2
Normal file
15
templates/JDownloader.service.j2
Normal file
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=JDownload Headless
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/opt/JDownloaderScripts/JDownloaderHeadlessCtl start
|
||||
ExecStop=/opt/JDownloaderScripts/JDownloaderHeadlessCtl stop
|
||||
User={{JD_Username}}
|
||||
Group={{JD_Username}}
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
2
vars/main.yml
Normal file
2
vars/main.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for JDowloader
|
Loading…
Reference in New Issue
Block a user