From c4780cf518492aef9759d48f5bc3d006a1aa5733 Mon Sep 17 00:00:00 2001 From: L3D Date: Wed, 29 Jan 2020 13:58:23 +0100 Subject: [PATCH] compile ranger if needed --- defaults/main.yml | 4 ++++ tasks/compile_ranger.yml | 35 +++++++++++++++++++++++++++++++++++ tasks/main.yml | 11 +++++++++++ 3 files changed, 50 insertions(+) create mode 100644 tasks/compile_ranger.yml diff --git a/defaults/main.yml b/defaults/main.yml index 1c4eebc..a0ba43f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,6 @@ --- submodules_versioncheck: true + +ranger_repo: 'https://github.com/ranger/ranger.git' +ranger_branch: 'master' +ranger_download_directory: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads/ranger') }}" diff --git a/tasks/compile_ranger.yml b/tasks/compile_ranger.yml new file mode 100644 index 0000000..b611b44 --- /dev/null +++ b/tasks/compile_ranger.yml @@ -0,0 +1,35 @@ +--- +- name: download ranger git repo + git: + repo: "{{ ranger_repo }}" + dest: "{{ ranger_download_directory }}" + version: "{{ ranger_branch }}" + +- name: install build packages + become: true + package: + name: + - make + - git + - vim + state: present + +- name: Run 'install' target as root + become: yes + make: + chdir: "{{ ranger_download_directory }}" + target: install + when: ansible_python_version[:1] == '3' + +- name: install python3 + become: true + package: + name: python3 + state: present + +- name: install ranger with python3 + become: yes + command: python3 setup.py install --optimize=1 + args: + chdir: "{{ ranger_download_directory }}" + creates: '/usr/local/bin/ranger' diff --git a/tasks/main.yml b/tasks/main.yml index 183d982..e0d266e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,3 +2,14 @@ - include_tasks: versioncheck.yml when: submodules_versioncheck|bool +- name: install ranger + become: yes + package: + name: ranger + state: present + register: install_ranger + ignore_errors: yes + +- include_tasks: compile_ranger.yml + when: install_ranger.failed +