Skip to content

Commit

Permalink
cloudplow: fill out sabnzbd apikey when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Jul 7, 2023
1 parent 498c9b4 commit d46bfea
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
25 changes: 24 additions & 1 deletion roles/cloudplow/tasks/subtasks/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
name: plex_auth_token
when: plex_account_is_enabled

- name: Settings | Check if SABnzbd is installed
ansible.builtin.stat:
path: "{{ sabnzbd_paths_config_location }}"
register: stat_sabnzbd

- name: Settings | Lookup SABnzbd API Key
ansible.builtin.set_fact:
sabnzbd_apikey: "{{ lookup('file', sabnzbd_paths_config_location) | regex_search('^api_key *= *.*', multiline=True) | regex_replace('.*= *(.*)$', '\\1') }}"
when: stat_sabnzbd.stat.exists

- name: Settings | Check if 'config.json' exists
ansible.builtin.stat:
path: "{{ cloudplow_config_path }}"
Expand Down Expand Up @@ -51,9 +61,22 @@

- name: Settings | Update NZBGet credentials in 'config.json'
ansible.builtin.shell: |
jq '.nzbget.url = "{{ nzbget_web_url_with_login }}"' {{ cloudplow_config_path }} | sponge {{ cloudplow_config_path }}
jq '.nzbget.url = "{{ nzbget_web_local_url_web_login }}"' {{ cloudplow_config_path }} | sponge {{ cloudplow_config_path }}
become: true
become_user: "{{ user.name }}"

- name: Settings | Update SABnzbd URL in 'config.json'
ansible.builtin.shell: |
jq '.sabnzbd.url = "{{ sabnzbd_web_local_url }}"' {{ cloudplow_config_path }} | sponge {{ cloudplow_config_path }}
become: true
become_user: "{{ user.name }}"

- name: Settings | Update SABnzbd API Key in 'config.json'
ansible.builtin.shell: |
jq '.sabnzbd.apikey = "{{ sabnzbd_apikey }}"' {{ cloudplow_config_path }} | sponge {{ cloudplow_config_path }}
become: true
become_user: "{{ user.name }}"
when: stat_sabnzbd.stat.exists

- name: Settings | Update Plex URL in 'config.json'
ansible.builtin.shell: |
Expand Down
24 changes: 15 additions & 9 deletions roles/cloudplow/templates/config.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
"notifications": {},
"nzbget": {
"enabled": false,
"url": "{{ nzbget_web_url_with_login }}"
"url": "{{ nzbget_web_local_url_web_login }}"
},
"plex": {
"enabled": false,
"url": "{{ plex_web_url }}",
"token": "{{ plex_auth_token | default('') }}",
"poll_interval": 60,
"notifications": false,
"ignore_local_streams": true,
"max_streams_before_throttle": 1,
"notifications": false,
"poll_interval": 60,
"rclone": {
"throttle_speeds": {
"0": "1000M",
Expand All @@ -27,11 +26,14 @@
"5": "10M"
},
"url": "http://localhost:7949"
}
},
"token": "{{ plex_auth_token | default('') }}",
"url": "{{ plex_web_url }}"
},
"remotes": {
"{{ rclone.remotes[0].remote }}": {
"hidden_remote": "",
"rclone_command": "move",
"rclone_excludes": [
"**partial~",
"**_HIDDEN~",
Expand Down Expand Up @@ -61,13 +63,17 @@
"timeout": 62
}
},
"rclone_command": "move",
"remove_empty_dir_depth": 2,
"sync_remote": "{{ rclone.remotes[0].remote }}:/Media",
"upload_folder": "/mnt/local/Media",
"upload_remote": "{{ rclone.remotes[0].remote }}:/Media"
}
},
"sabnzbd": {
"apikey": "{{ sabnzbd_apikey | default('') }}",
"enabled": false,
"url": "{{ sabnzbd_web_local_url }}"
},
"syncer": {},
"uploader": {
"{{ rclone.remotes[0].remote }}": {
Expand All @@ -77,10 +83,10 @@
"opened_excludes": [
"/downloads/"
],
"service_account_path": "",
"size_excludes": [
"downloads/*"
],
"service_account_path": ""
]
}
}
}

0 comments on commit d46bfea

Please sign in to comment.