Update intellij task for updating
This commit is contained in:
parent
a96de9395d
commit
cf122b6a52
56
roles/intellij/tasks/install.yml
Normal file
56
roles/intellij/tasks/install.yml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
- name: install jmespath for json_query
|
||||||
|
become: yes
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
pkg:
|
||||||
|
- python3-jmespath
|
||||||
|
|
||||||
|
- name: "Get IntelliJ version"
|
||||||
|
uri:
|
||||||
|
url: https://data.services.jetbrains.com/products/releases?code=IIU
|
||||||
|
body_format: json
|
||||||
|
register: idea_info
|
||||||
|
|
||||||
|
- name: Create temp dir
|
||||||
|
file:
|
||||||
|
path: "{{ tmp_dir }}"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: "Download IntelliJ Ultimate"
|
||||||
|
become: yes
|
||||||
|
unarchive:
|
||||||
|
src: "{{ idea_info.json | json_query('IIU[0].downloads.linux.link') }}"
|
||||||
|
dest: "{{ tmp_dir }}"
|
||||||
|
remote_src: yes
|
||||||
|
|
||||||
|
- name: get folder name
|
||||||
|
shell: ls "{{ tmp_dir }}"
|
||||||
|
register: dir_name
|
||||||
|
|
||||||
|
- name: Check if old version exists
|
||||||
|
stat:
|
||||||
|
path: "{{idea_dir}}"
|
||||||
|
register: intellij_dir
|
||||||
|
|
||||||
|
- name: Move old version if available
|
||||||
|
become: yes
|
||||||
|
command: mv {{idea_dir}} {{idea_dir}}-{{local_intellij_version}}
|
||||||
|
when:
|
||||||
|
- intellij_dir.stat.exists
|
||||||
|
|
||||||
|
- name: Copy to final directory
|
||||||
|
become: yes
|
||||||
|
command: "cp -ra {{ tmp_dir }}/{{ dir_name.stdout }} {{ idea_dir }}"
|
||||||
|
|
||||||
|
- name: Remove temp directory
|
||||||
|
become: yes
|
||||||
|
file:
|
||||||
|
path: "{{ tmp_dir }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Create symbolic link
|
||||||
|
become: yes
|
||||||
|
file:
|
||||||
|
src: "/opt/idea/bin/idea.sh"
|
||||||
|
dest: "/usr/local/bin/idea"
|
||||||
|
state: link
|
@ -1,49 +1,24 @@
|
|||||||
- name: install jmespath for json_query
|
|
||||||
become: yes
|
|
||||||
apt:
|
|
||||||
update_cache: yes
|
|
||||||
pkg:
|
|
||||||
- python3-jmespath
|
|
||||||
|
|
||||||
- name: "Get IntelliJ version"
|
- name: "Get IntelliJ version"
|
||||||
uri:
|
uri:
|
||||||
url: https://data.services.jetbrains.com/products/releases?code=IIU
|
url: https://data.services.jetbrains.com/products/releases?code=IIU
|
||||||
body_format: json
|
body_format: json
|
||||||
register: idea_info
|
register: idea_info
|
||||||
|
|
||||||
- debug: msg="{{ idea_info.json | json_query('IIU[0].downloads.linux.link') }}"
|
- name: "Check if intellij is installed"
|
||||||
|
stat:
|
||||||
|
path: "{{idea_dir}}/product-info.json"
|
||||||
|
register: local_version_info_file
|
||||||
|
|
||||||
- name: Create temp dir
|
- name: "Check installed version"
|
||||||
file:
|
when:
|
||||||
path: "{{ tmp_dir }}"
|
- local_version_info_file.stat.exists
|
||||||
state: directory
|
shell: cat {{idea_dir}}/product-info.json
|
||||||
|
register: local_version_info_file
|
||||||
|
|
||||||
- name: "Download IntelliJ Ultimate"
|
- name: "Set version info fact"
|
||||||
become: yes
|
set_fact:
|
||||||
unarchive:
|
local_intellij_version: "{{ local_version_info_file.stdout | from_json | json_query('version') }}"
|
||||||
src: "{{ idea_info.json | json_query('IIU[0].downloads.linux.link') }}"
|
upstream_intellij_version: "{{ idea_info.json | json_query('IIU[0].version') }}"
|
||||||
dest: "{{ tmp_dir }}"
|
|
||||||
remote_src: yes
|
|
||||||
|
|
||||||
- name: get folder name
|
- import_tasks: install.yml
|
||||||
shell: ls "{{ tmp_dir }}"
|
when: local_version_info_file is undefined or local_intellij_version != upstream_intellij_version
|
||||||
register: dir_name
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: Copy to final directory
|
|
||||||
become: yes
|
|
||||||
command: "cp -ra {{ tmp_dir }}/{{ dir_name.stdout }} {{ idea_dir }}"
|
|
||||||
|
|
||||||
- name: Remove temp directory
|
|
||||||
become: yes
|
|
||||||
file:
|
|
||||||
path: "{{ tmp_dir }}"
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Create symbolic link
|
|
||||||
become: yes
|
|
||||||
file:
|
|
||||||
src: "/opt/idea/bin/idea.sh"
|
|
||||||
dest: "/usr/local/bin/idea"
|
|
||||||
state: link
|
|
||||||
|
Loading…
Reference in New Issue
Block a user