120 lines
5.5 KiB
YAML
120 lines
5.5 KiB
YAML
---
|
|
# 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 |