From 81337dc1b8066f12631cd66126fe87ceef67886a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sun, 10 Jan 2021 14:57:06 +0100 Subject: [PATCH] Failed attempt Curse you Ansible and Termux --- config/automatrop/ansible.cfg | 1 + config/automatrop/hosts | 4 +- config/automatrop/playbooks/default.yml | 7 +- .../automatrop/roles/software/tasks/base.yml | 55 +++++++++++ .../automatrop/roles/software/tasks/main.yml | 96 +++++++++++++++++++ 5 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 config/automatrop/roles/software/tasks/base.yml create mode 100644 config/automatrop/roles/software/tasks/main.yml diff --git a/config/automatrop/ansible.cfg b/config/automatrop/ansible.cfg index a7ae9ee..a1d86ba 100644 --- a/config/automatrop/ansible.cfg +++ b/config/automatrop/ansible.cfg @@ -2,6 +2,7 @@ inventory=hosts roles_path=roles interpreter_python=auto +library=plugins/modules [ssh_connection] pipelining = True # does not work with requiretty in /etc/sudoers diff --git a/config/automatrop/hosts b/config/automatrop/hosts index 2fbb50c..cf45a5c 100644 --- a/config/automatrop/hosts +++ b/config/automatrop/hosts @@ -1 +1,3 @@ -localhost +curacao.geoffrey.frogeye.fr +triffle.geoffrey.frogeye.fr +bufobufo.frogeye.nl diff --git a/config/automatrop/playbooks/default.yml b/config/automatrop/playbooks/default.yml index e8cdfc3..37e7239 100644 --- a/config/automatrop/playbooks/default.yml +++ b/config/automatrop/playbooks/default.yml @@ -1,7 +1,10 @@ - name: Default - hosts: localhost - connection: local + hosts: all roles: + - role: software + tags: software - role: mnussbaum.base16-builder-ansible # Required for color + tags: color - role: color + tags: color diff --git a/config/automatrop/roles/software/tasks/base.yml b/config/automatrop/roles/software/tasks/base.yml new file mode 100644 index 0000000..2d72779 --- /dev/null +++ b/config/automatrop/roles/software/tasks/base.yml @@ -0,0 +1,55 @@ +- name: Install base shell packages (Pacman) + pacman: + name: + - base + - coreutils + - bash + - grep + - sed + - tar + - openssl # Used for machines script + when: arch + +- name: Install base shell packages (Apt) + apt: + name: + - coreutils + - bash + - grep + - sed + - tar + - openssl + when: apt + +- name: Install extended shell packages (Pacman) + pacman: + name: + - moreutils + - tmux + - bash-completion + - fzf + - highlight + - powerline-go-bin + when: arch + +- name: Install extended shell packages (Debian) + pacman: + name: + - moreutils + - tmux + - bash-completion + - fzf + - highlight + - powerline-go + when: debian + +- name: Install extended shell packages (Termux) + pacman: + name: + - moreutils + - tmux + - bash-completion + - fzf + # - highlight + # - powerline-go + when: termux diff --git a/config/automatrop/roles/software/tasks/main.yml b/config/automatrop/roles/software/tasks/main.yml new file mode 100644 index 0000000..51c2a62 --- /dev/null +++ b/config/automatrop/roles/software/tasks/main.yml @@ -0,0 +1,96 @@ +- name: Set variables + set_fact: + arch: "{{ ansible_distribution == 'Archlinux' }}" + termux: "{{ ansible_distribution == 'OtherLinux' and ansible_python.executable == '/data/data/com.termux/files/usr/bin/python' }}" + debian: "{{ ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' }}" + +- name: Set secondary variables + set_fact: + pacman: "{{ arch }}" + apt: "{{ termux or debian }}" + sudo: "{{ not termux }}" + +# TODO Install python if not done + +- name: Install python-apt dependency for Termux + block: + # TODO Check if the correct version + - name: Check for DistUtilsExtra (Termux) + command: python -c 'import DistUtilsExtra' + changed_when: False + rescue: + - name: Create temporarty folder for DistUtilsExtra (Termux) + tempfile: + state: directory + suffix: python-distutils-extra + # path: /data/data/com.termux/files/usr/tmp/ + register: pde_tempdir + + - name: Download DistUtilsExtra (Termux) + get_url: + url: "https://launchpad.net/python-distutils-extra/trunk/{{ version }}/+download/python-distutils-extra-{{ version }}.tar.gz" + dest: "{{ pde_tempdir.path }}/python-distutils-extra.tar.gz" + + - name: Extract DistUtilsExtra (Termux) + unarchive: + src: "{{ pde_tempdir.path }}/python-distutils-extra.tar.gz" + remote_src: yes + dest: "{{ pde_tempdir.path }}" + + - name: Install DistUtilsExtra (Termux) + command: + cmd: python3 setup.py install + chdir: "{{ pde_tempdir.path }}/python-distutils-extra-{{ version }}" + when: termux + vars: + version: 2.39 + +- name: Install python-apt (Termux) + pip: + name: python-apt + when: termux + +# Collecting python-apt +# Using cached python-apt-0.7.8.tar.bz2 (49 kB) +# ERROR: Command errored out with exit status 1: +# command: /data/data/com.termux/files/usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/data/data/com.termux/files/usr/tmp/pip-install-dsga__i7/python-apt/setup.py'"'"'; __file__='"'"'/data/data/com.termux/files/usr/tmp/pip-install-dsga__i7/python-apt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /data/data/com.termux/files/usr/tmp/pip-pip-egg-info-ptpprl0m +# cwd: /data/data/com.termux/files/usr/tmp/pip-install-dsga__i7/python-apt/ +# Complete output (5 lines): +# Traceback (most recent call last): +# File "", line 1, in +# File "/data/data/com.termux/files/usr/tmp/pip-install-dsga__i7/python-apt/setup.py", line 11, in +# string.split(parse_makefile("python/makefile")["APT_PKG_SRC"])) +# AttributeError: module 'string' has no attribute 'split' +# ---------------------------------------- +# ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. +# WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available. +# You should consider upgrading via the '/data/data/com.termux/files/usr/bin/python3 -m pip install --upgrade pip' command. + +# Install alternative package managers +- name: Install AUR package manager + aur: + name: yay-bin + when: arch + +- name: Install python pip (Pacman) + pacman: + name: python-pip + when: arch + become: "{{ sudo }}" + become_user: root + +- name: Install python pip (Debian) + apt: + name: python3-pip + when: debian + become: "{{ sudo }}" + become_user: root + +# Termux: pip is included with Python + +- name: Install base packages + include_tasks: + file: base.yml + apply: + become: "{{ sudo }}" + become_user: root