From 6d3c66540b639c0716fa6744280cb0dc324d67a1 Mon Sep 17 00:00:00 2001 From: Dimitris Kafetzis Date: Thu, 15 Dec 2022 00:16:04 +0800 Subject: [PATCH] Use roles from collection, add ubuntu 22.04 and various fixes. --- ansible/.ansible-lint => .ansible-lint | 2 + .github/workflows/main.yml | 37 +++++- ansible/.gitignore => .gitignore | 2 + .yamllint.yml | 14 +++ Dockerfile | 1 - Dockerfile.fullBuild | 78 ------------ Dockerfile.noIntegrationTests | 63 ---------- Makefile | 16 +++ README.md | 2 +- ansible/00-add-cronjob.yml | 9 -- ansible/01-provision-all.yml | 15 --- ansible/ansible.cfg | 7 +- ansible/group_vars/all/software-debian.yml | 10 +- .../workstation/workstation_inventory | 2 +- ansible/requirements.yml | 10 ++ ansible/roles/admin_cronjob/defaults/main.yml | 18 --- ansible/roles/admin_cronjob/tasks/debian.yml | 26 ---- ansible/roles/admin_cronjob/tasks/main.yml | 5 - .../templates/admin-cronjob.sh.j2 | 31 ----- .../settings/application/defaults/main.yml | 3 - .../settings/application/tasks/dconf.yml | 16 --- .../settings/application/tasks/dot-files.yml | 39 ------ .../settings/application/tasks/gsettings.yml | 35 ------ .../roles/settings/application/tasks/main.yml | 21 ---- .../settings/application/tasks/vscode.yml | 23 ---- .../application/templates/10-wakeup.rules.j2 | 28 ----- .../templates/bash_profile.dkafetzi.j2 | 11 -- .../templates/bashrc_aliases.dkafetzi.j2 | 3 - .../bashrc_autocompletion.dkafetzi.j2 | 11 -- .../templates/bashrc_common.dkafetzi.j2 | 25 ---- .../templates/gitconfig.dkafetzi.j2 | 41 ------ .../application/templates/inputrc.dkafetzi.j2 | 12 -- .../templates/neovim.init.vim.dkafetzi.j2 | 12 -- .../application/templates/profile.d.golang.j2 | 6 - .../application/templates/profile.dkafetzi.j2 | 4 - .../templates/ssh.config.dkafetzi.j2 | 16 --- .../application/templates/sudoers.d.admin.j2 | 4 - .../application/templates/vimrc.dkafetzi.j2 | 3 - .../vscode.settings.json.dkafetzi.j2 | 9 -- ansible/roles/settings/user/tasks/main.yml | 16 --- ansible/roles/software-k8s-toolbox/Readme.md | 2 - .../roles/software-k8s-toolbox/helm/LICENSE | 21 ---- .../roles/software-k8s-toolbox/helm/README.md | 56 --------- .../helm/defaults/main.yml | 8 -- .../software-k8s-toolbox/helm/tasks/main.yml | 38 ------ .../software-k8s-toolbox/helm/vars/main.yml | 5 - .../roles/software-k8s-toolbox/k9s/LICENSE | 21 ---- .../roles/software-k8s-toolbox/k9s/README.md | 56 --------- .../k9s/defaults/main.yml | 6 - .../software-k8s-toolbox/k9s/tasks/main.yml | 37 ------ .../software-k8s-toolbox/k9s/vars/main.yml | 5 - .../software-k8s-toolbox/kubectl/LICENSE | 21 ---- .../software-k8s-toolbox/kubectl/README.md | 53 -------- .../kubectl/defaults/main.yml | 3 - .../kubectl/tasks/main.yml | 9 -- .../software-k8s-toolbox/kubectx/LICENSE | 21 ---- .../software-k8s-toolbox/kubectx/README.md | 58 --------- .../kubectx/defaults/main.yml | 4 - .../kubectx/tasks/main.yml | 18 --- .../kubectx/vars/main.yml | 6 - .../software-k8s-toolbox/minikube/LICENSE | 21 ---- .../software-k8s-toolbox/minikube/README.md | 53 -------- .../minikube/defaults/main.yml | 3 - .../minikube/tasks/main.yml | 8 -- .../roles/software-k8s-toolbox/stern/LICENSE | 21 ---- .../software-k8s-toolbox/stern/README.md | 55 -------- .../stern/defaults/main.yml | 6 - .../software-k8s-toolbox/stern/tasks/main.yml | 34 ----- .../software-k8s-toolbox/stern/vars/main.yml | 5 - ansible/roles/software/defaults/main.yml | 9 -- ansible/roles/software/tasks/cleanup.yml | 8 -- .../software/tasks/configure_alternative.yml | 14 --- ansible/roles/software/tasks/install_k8s.yml | 42 ------- .../roles/software/tasks/install_latest.yml | 61 --------- ansible/roles/software/tasks/main.yml | 12 -- ansible/roles/software/tasks/update_cache.yml | 10 -- ansible/roles/software/tasks/upgrade.yml | 8 -- ansible/roles/software/vars/main.yml | 8 -- .../roles/system/bluetooth/defaults/main.yml | 6 - .../system/bluetooth/tasks/enable-on-boot.yml | 31 ----- .../bluetooth/tasks/enable-on-login.yml | 43 ------- ansible/roles/system/bluetooth/tasks/main.yml | 28 ----- .../bluetooth/tasks/update-pulseaudio.yml | 23 ---- .../initramfs-tools.hooks.bluetooth.j2 | 118 ------------------ ...fs-tools.scripts.local-bottom.bluetooth.j2 | 25 ---- ...ramfs-tools.scripts.local-top.bluetooth.j2 | 46 ------- .../lib.systemd.system-sleep.bluetooth.j2 | 14 --- ansible/roles/system/locale/defaults/main.yml | 8 -- .../system/locale/tasks/locale-debian.yml | 40 ------ ansible/roles/system/locale/tasks/main.yml | 8 -- .../package_manager/apt/defaults/main.yml | 3 - .../package_manager/apt/tasks/add_key.yml | 6 - .../apt/tasks/add_repository.yml | 8 -- .../package_manager/apt/tasks/cleanup.yml | 11 -- .../package_manager/apt/tasks/configure.yml | 20 --- .../package_manager/apt/tasks/install.yml | 32 ----- .../package_manager/apt/tasks/upgrade.yml | 38 ------ .../package_manager/pip/tasks/install.yml | 10 -- .../package_manager/snap/defaults/main.yml | 3 - .../package_manager/snap/tasks/install.yml | 15 --- .../roles/system/timezone/defaults/main.yml | 6 - ansible/roles/system/timezone/tasks/main.yml | 10 -- .../system/update-initramfs/tasks/main.yml | 15 --- ansible/roles/system/user/defaults/main.yml | 5 - ansible/roles/system/user/tasks/main.yml | 16 --- .../utils/are_we_in_docker/tasks/main.yml | 19 --- ansible/settings-system.yml | 11 -- ansible/settings-user.yml | 15 --- ansible/software-install.yml | 31 ----- ansible/software-update.yml | 18 --- ansible/system-bluetooth.yml | 9 -- ansible/system-user.yml | 14 --- ansible/tools-gather_facts.yml | 6 - docker-entrypoint-one-time.sh | 5 - docker-entrypoint-scheduled.sh | 5 - docker-entrypoint.sh | 6 - docker/Dockerfile.ubuntu-20.04 | 115 +++++++++++++++++ docker/Dockerfile.ubuntu-22.04 | 115 +++++++++++++++++ docker/docker-entrypoint.sh | 14 +++ scripts/add-cronjob-debian.sh | 33 ++--- scripts/one-time-debian.sh | 99 +++++++++------ scripts/scheduled-debian.sh | 42 +++---- scripts/setup-env.sh | 49 ++++++++ scripts/utils.sh | 6 + 124 files changed, 485 insertions(+), 2227 deletions(-) rename ansible/.ansible-lint => .ansible-lint (98%) rename ansible/.gitignore => .gitignore (57%) create mode 100644 .yamllint.yml delete mode 120000 Dockerfile delete mode 100644 Dockerfile.fullBuild delete mode 100644 Dockerfile.noIntegrationTests create mode 100644 Makefile delete mode 100644 ansible/00-add-cronjob.yml delete mode 100644 ansible/01-provision-all.yml create mode 100644 ansible/requirements.yml delete mode 100644 ansible/roles/admin_cronjob/defaults/main.yml delete mode 100644 ansible/roles/admin_cronjob/tasks/debian.yml delete mode 100644 ansible/roles/admin_cronjob/tasks/main.yml delete mode 100644 ansible/roles/admin_cronjob/templates/admin-cronjob.sh.j2 delete mode 100644 ansible/roles/settings/application/defaults/main.yml delete mode 100644 ansible/roles/settings/application/tasks/dconf.yml delete mode 100644 ansible/roles/settings/application/tasks/dot-files.yml delete mode 100644 ansible/roles/settings/application/tasks/gsettings.yml delete mode 100644 ansible/roles/settings/application/tasks/main.yml delete mode 100644 ansible/roles/settings/application/tasks/vscode.yml delete mode 100644 ansible/roles/settings/application/templates/10-wakeup.rules.j2 delete mode 100644 ansible/roles/settings/application/templates/bash_profile.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/bashrc_aliases.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/bashrc_autocompletion.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/bashrc_common.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/gitconfig.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/inputrc.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/neovim.init.vim.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/profile.d.golang.j2 delete mode 100644 ansible/roles/settings/application/templates/profile.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/ssh.config.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/sudoers.d.admin.j2 delete mode 100644 ansible/roles/settings/application/templates/vimrc.dkafetzi.j2 delete mode 100644 ansible/roles/settings/application/templates/vscode.settings.json.dkafetzi.j2 delete mode 100644 ansible/roles/settings/user/tasks/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/Readme.md delete mode 100644 ansible/roles/software-k8s-toolbox/helm/LICENSE delete mode 100644 ansible/roles/software-k8s-toolbox/helm/README.md delete mode 100644 ansible/roles/software-k8s-toolbox/helm/defaults/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/helm/tasks/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/helm/vars/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/k9s/LICENSE delete mode 100644 ansible/roles/software-k8s-toolbox/k9s/README.md delete mode 100644 ansible/roles/software-k8s-toolbox/k9s/defaults/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/k9s/tasks/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/k9s/vars/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/kubectl/LICENSE delete mode 100644 ansible/roles/software-k8s-toolbox/kubectl/README.md delete mode 100644 ansible/roles/software-k8s-toolbox/kubectl/defaults/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/kubectl/tasks/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/kubectx/LICENSE delete mode 100644 ansible/roles/software-k8s-toolbox/kubectx/README.md delete mode 100644 ansible/roles/software-k8s-toolbox/kubectx/defaults/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/kubectx/tasks/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/kubectx/vars/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/minikube/LICENSE delete mode 100644 ansible/roles/software-k8s-toolbox/minikube/README.md delete mode 100644 ansible/roles/software-k8s-toolbox/minikube/defaults/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/minikube/tasks/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/stern/LICENSE delete mode 100644 ansible/roles/software-k8s-toolbox/stern/README.md delete mode 100644 ansible/roles/software-k8s-toolbox/stern/defaults/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/stern/tasks/main.yml delete mode 100644 ansible/roles/software-k8s-toolbox/stern/vars/main.yml delete mode 100644 ansible/roles/software/defaults/main.yml delete mode 100644 ansible/roles/software/tasks/cleanup.yml delete mode 100644 ansible/roles/software/tasks/configure_alternative.yml delete mode 100644 ansible/roles/software/tasks/install_k8s.yml delete mode 100644 ansible/roles/software/tasks/install_latest.yml delete mode 100644 ansible/roles/software/tasks/main.yml delete mode 100644 ansible/roles/software/tasks/update_cache.yml delete mode 100644 ansible/roles/software/tasks/upgrade.yml delete mode 100644 ansible/roles/software/vars/main.yml delete mode 100644 ansible/roles/system/bluetooth/defaults/main.yml delete mode 100644 ansible/roles/system/bluetooth/tasks/enable-on-boot.yml delete mode 100644 ansible/roles/system/bluetooth/tasks/enable-on-login.yml delete mode 100644 ansible/roles/system/bluetooth/tasks/main.yml delete mode 100644 ansible/roles/system/bluetooth/tasks/update-pulseaudio.yml delete mode 100644 ansible/roles/system/bluetooth/templates/initramfs-tools.hooks.bluetooth.j2 delete mode 100644 ansible/roles/system/bluetooth/templates/initramfs-tools.scripts.local-bottom.bluetooth.j2 delete mode 100644 ansible/roles/system/bluetooth/templates/initramfs-tools.scripts.local-top.bluetooth.j2 delete mode 100644 ansible/roles/system/bluetooth/templates/lib.systemd.system-sleep.bluetooth.j2 delete mode 100644 ansible/roles/system/locale/defaults/main.yml delete mode 100644 ansible/roles/system/locale/tasks/locale-debian.yml delete mode 100644 ansible/roles/system/locale/tasks/main.yml delete mode 100644 ansible/roles/system/package_manager/apt/defaults/main.yml delete mode 100644 ansible/roles/system/package_manager/apt/tasks/add_key.yml delete mode 100644 ansible/roles/system/package_manager/apt/tasks/add_repository.yml delete mode 100644 ansible/roles/system/package_manager/apt/tasks/cleanup.yml delete mode 100644 ansible/roles/system/package_manager/apt/tasks/configure.yml delete mode 100644 ansible/roles/system/package_manager/apt/tasks/install.yml delete mode 100644 ansible/roles/system/package_manager/apt/tasks/upgrade.yml delete mode 100644 ansible/roles/system/package_manager/pip/tasks/install.yml delete mode 100644 ansible/roles/system/package_manager/snap/defaults/main.yml delete mode 100644 ansible/roles/system/package_manager/snap/tasks/install.yml delete mode 100644 ansible/roles/system/timezone/defaults/main.yml delete mode 100644 ansible/roles/system/timezone/tasks/main.yml delete mode 100644 ansible/roles/system/update-initramfs/tasks/main.yml delete mode 100644 ansible/roles/system/user/defaults/main.yml delete mode 100644 ansible/roles/system/user/tasks/main.yml delete mode 100644 ansible/roles/utils/are_we_in_docker/tasks/main.yml delete mode 100644 ansible/settings-system.yml delete mode 100644 ansible/settings-user.yml delete mode 100644 ansible/software-install.yml delete mode 100644 ansible/software-update.yml delete mode 100644 ansible/system-bluetooth.yml delete mode 100644 ansible/system-user.yml delete mode 100644 ansible/tools-gather_facts.yml delete mode 100755 docker-entrypoint-one-time.sh delete mode 100755 docker-entrypoint-scheduled.sh delete mode 100755 docker-entrypoint.sh create mode 100644 docker/Dockerfile.ubuntu-20.04 create mode 100644 docker/Dockerfile.ubuntu-22.04 create mode 100755 docker/docker-entrypoint.sh create mode 100755 scripts/setup-env.sh create mode 100755 scripts/utils.sh diff --git a/ansible/.ansible-lint b/.ansible-lint similarity index 98% rename from ansible/.ansible-lint rename to .ansible-lint index e0d9e2a..9a3294e 100644 --- a/ansible/.ansible-lint +++ b/.ansible-lint @@ -57,6 +57,8 @@ warn_list: - skip_this_tag - git-latest - experimental # experimental is included in the implicit list + - yaml[commas] + - yaml[line-length] # - role-name # Offline mode disables installation of requirements.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d6f12e5..2251fa4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,13 +19,16 @@ on: jobs: - test: - name: Test on docker + test_end_to_end: + name: Test on various OSes + + runs-on: ubuntu-latest - runs-on: ${{ matrix.os }} strategy: + fail-fast: true matrix: - os: [ubuntu-20.04] + os: ["ubuntu-20.04", 'ubuntu-22.04'] + python: ["python3.7", "python3.8", "python3.9", "python3.10"] steps: - uses: actions/checkout@v2 @@ -37,5 +40,27 @@ jobs: GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV - - name: Build - run: ./docker-entrypoint.sh + echo "REPOSITORY=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV + + - name: Build docker image + run: > + docker build \ + -t automation:${{ matrix.os }} \ + -f docker/Dockerfile.${{ matrix.os }} \ + . + + - name: End to end test using locally checkedout code + run: > + docker run automation:${{ matrix.os }} \ + -e GIT_BRANCH=$GIT_BRANCH \ + -e REPOSITORY=$REPOSITORY \ + -e PYTHON_VERSION=${{ matrix.python }} + + - name: End to end test with code fetch from remote + run: > + docker run automation:${{ matrix.os }} \ + -e GIT_BRANCH=$GIT_BRANCH \ + -e REPOSITORY=$REPOSITORY \ + -e PYTHON_VERSION=${{ matrix.python }} \ + rm -f "/opt/automated-workstation/app/scripts/add-cronjob-debian.sh"; + /opt/docker/docker-entrypoint.sh diff --git a/ansible/.gitignore b/.gitignore similarity index 57% rename from ansible/.gitignore rename to .gitignore index 28a92f1..45ae53a 100644 --- a/ansible/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ +# Ansible .ansibleFactsCacheDir/* +*.retry diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..7250333 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,14 @@ +--- + +extends: default + +rules: + braces: + max-spaces-inside: -1 + + commas: + # Disable check for space after commas so that we can align our values visually. + max-spaces-after: -1 + + line-length: + max: 160 diff --git a/Dockerfile b/Dockerfile deleted file mode 120000 index 448e8a0..0000000 --- a/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -Dockerfile.noIntegrationTests \ No newline at end of file diff --git a/Dockerfile.fullBuild b/Dockerfile.fullBuild deleted file mode 100644 index 6dd7aeb..0000000 --- a/Dockerfile.fullBuild +++ /dev/null @@ -1,78 +0,0 @@ -# ----------------------------------------------------------------------------- -# We need to have a base so that we do not install ansible, sudo etc by default. -# We want the script to handle them. -FROM ubuntu:20.04 as base - -ENV DEBIAN_FRONTEND=noninteractive - -# Let's install some helpful tools -RUN apt-get update -qq >/dev/null 2>&1 && \ - apt-get install --yes --no-install-recommends \ - apt-transport-https \ - apt-utils \ - ca-certificates \ - cron \ - curl \ - dbus-x11 \ - dirmngr \ - less \ - libnotify-bin \ - iputils-ping \ - net-tools \ - netcat \ - notify-osd \ - software-properties-common \ - telnet \ - vim && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -WORKDIR /user/app/workdir - -# ----------------------------------------------------------------------------- -FROM base as pre-test - -RUN apt-get update --yes && \ - apt-get install --yes --no-install-recommends sudo - -RUN sudo add-apt-repository --yes ppa:deadsnakes/ppa && \ - sudo apt-add-repository --yes ppa:ansible/ansible && \ - apt-get update -qq >/dev/null 2>&1 && \ - apt-get install -qq --yes --no-install-recommends \ - ansible \ - python3.8 \ - python3-apt \ - python3-pip - -RUN pip3 install --quiet \ - ansible-lint \ - yamllint - -COPY ansible ./ - -RUN ansible-lint - -# ----------------------------------------------------------------------------- -FROM base as test-one-time - -COPY docker-entrypoint* ./ -COPY ansible ./ansible/ -COPY scripts ./scripts/ - -RUN chmod 755 docker-entrypoint* -RUN ./docker-entrypoint-one-time.sh - -# ----------------------------------------------------------------------------- -FROM test-one-time as test-scheduled - -RUN ./docker-entrypoint-scheduled.sh - -# ----------------------------------------------------------------------------- -FROM base as build - -COPY docker-entrypoint* ./ -COPY ansible ./ansible/ -COPY scripts ./scripts/ - -RUN chmod 755 docker-entrypoint* -ENTRYPOINT ["./docker-entrypoint.sh"] diff --git a/Dockerfile.noIntegrationTests b/Dockerfile.noIntegrationTests deleted file mode 100644 index eacf1fe..0000000 --- a/Dockerfile.noIntegrationTests +++ /dev/null @@ -1,63 +0,0 @@ -# ----------------------------------------------------------------------------- -# We need to have a base so that we do not install ansible, sudo etc by default. -# We want the script to handle them. -FROM ubuntu:20.04 as base - -ENV DEBIAN_FRONTEND=noninteractive - -# Let's install some helpful tools -RUN apt-get update -qq >/dev/null 2>&1 && \ - apt-get install --yes --no-install-recommends \ - apt-transport-https \ - apt-utils \ - ca-certificates \ - cron \ - curl \ - dbus-x11 \ - dirmngr \ - less \ - libnotify-bin \ - iputils-ping \ - net-tools \ - netcat \ - notify-osd \ - software-properties-common \ - telnet \ - vim && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -WORKDIR /user/app/workdir - -# ----------------------------------------------------------------------------- -FROM base as pre-test - -RUN apt-get update --yes && \ - apt-get install --yes --no-install-recommends sudo - -RUN sudo add-apt-repository --yes ppa:deadsnakes/ppa && \ - sudo apt-add-repository --yes ppa:ansible/ansible && \ - apt-get update -qq >/dev/null 2>&1 && \ - apt-get install -qq --yes --no-install-recommends \ - ansible \ - python3.8 \ - python3-apt \ - python3-pip - -RUN pip3 install --quiet \ - ansible-lint \ - yamllint - -COPY ansible ./ - -RUN ansible-lint - -# ----------------------------------------------------------------------------- -FROM base as build - -COPY docker-entrypoint* ./ -COPY ansible ./ansible/ -COPY scripts ./scripts/ - -RUN chmod 755 docker-entrypoint* -ENTRYPOINT ["./docker-entrypoint.sh"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4b7684c --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +run: + ./scripts/one-time-debian.sh + ./scripts/scheduled-debian.sh + +lint: + . ./.venv/bin/activate + ansible-lint -c .ansible-lint + +prepare_env: + python3.9 -m venv .venv && \ + . ./.venv/bin/activate && \ + pip install --upgrade \ + pip \ + ansible \ + ansible-lint \ + yamllint diff --git a/README.md b/README.md index 154dfcf..ae866ad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Overview -This is an effort to provide scripts to setup my workstation in an automated, reproducible way. +This is an effort to provide scripts to setup my workstation in an automated, reproducible way. The scripts are meant to be generic and parameterised based on the provided group_vars. ## Status [![ubuntu-ci status](https://github.com/amolofos/automated-workstation-setup/workflows/ubuntu-ci/badge.svg)](https://github.com/amolofos/automated-workstation-setup/actions) diff --git a/ansible/00-add-cronjob.yml b/ansible/00-add-cronjob.yml deleted file mode 100644 index a9920ac..0000000 --- a/ansible/00-add-cronjob.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- import_playbook: tools-gather_facts.yml - -- name: Setup software - hosts: all - roles: - - - role: admin_cronjob diff --git a/ansible/01-provision-all.yml b/ansible/01-provision-all.yml deleted file mode 100644 index 4982d9e..0000000 --- a/ansible/01-provision-all.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- - -- import_playbook: tools-gather_facts.yml - -- import_playbook: software-install.yml - -- import_playbook: software-update.yml - -- import_playbook: settings-system.yml - -- import_playbook: system-user.yml - -- import_playbook: settings-user.yml - -- import_playbook: system-bluetooth.yml diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index 2ef5587..d29ea0a 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -61,11 +61,12 @@ gathering = smart #inject_facts_as_vars = True # Paths to search for collections, colon separated -# collections_paths = ~/.ansible/collections:/usr/share/ansible/collections +#collections_paths = ~/.ansible/collections:/usr/share/ansible/collections +collections_paths = ./collections:~/.ansible/collections # Paths to search for roles, colon separated #roles_path = ~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles -roles_path = ./roles +roles_path = ./roles:~/.ansible/roles # Host key checking is enabled by default #host_key_checking = True @@ -86,7 +87,7 @@ roles_path = ./roles # # Enable callback plugins, they can output to stdout but cannot be 'stdout' type. #callback_whitelist = timer, mail -callback_whitelist = profile_tasks +callbacks_enabled = profile_tasks # Determine whether includes in tasks and handlers are "static" by # default. As of 2.0, includes are dynamic by default. Setting these diff --git a/ansible/group_vars/all/software-debian.yml b/ansible/group_vars/all/software-debian.yml index 73601d6..b638d59 100644 --- a/ansible/group_vars/all/software-debian.yml +++ b/ansible/group_vars/all/software-debian.yml @@ -168,6 +168,10 @@ software: - python3.9-dev - python3.9-distutils - python3.9-venv + - python3.10 + - python3.10-dev + - python3.10-distutils + - python3.10-venv - python3-apt - python3-pip media: @@ -189,7 +193,7 @@ software: - xmltodict - yamllint -# Each command should output "Changed" to stdout so the task reports it as changed. + # Each command should output "Changed" to stdout so the task reports it as changed. yaml[line-length] custom: # Should we create a role to install the latest go version? - "if [ ! -d /usr/local/go ] || [ \"`/usr/local/go/bin/go version | grep go1.17 | wc -l`\" -eq 0 ]; then sudo rm -rf /usr/local/go && wget --quiet https://dl.google.com/go/go1.17.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local; echo Changed; fi" @@ -211,6 +215,10 @@ software: path: "/usr/bin/python3.8" link: "/usr/bin/python" priority: 1000 + - name: "python" + path: "/usr/bin/python3.9" + link: "/usr/bin/python" + priority: 1000 - name: "vi" path: "/usr/bin/nvim" link: "/bin/vi" diff --git a/ansible/inventory/workstation/workstation_inventory b/ansible/inventory/workstation/workstation_inventory index b34ce0d..ae67b4e 100644 --- a/ansible/inventory/workstation/workstation_inventory +++ b/ansible/inventory/workstation/workstation_inventory @@ -2,4 +2,4 @@ localhost ansible_host=127.0.0.1 ansible_connection=local [workstation:vars] -ansible_python_interpreter=/usr/bin/python3.8 +ansible_python_interpreter=/usr/bin/python3 diff --git a/ansible/requirements.yml b/ansible/requirements.yml new file mode 100644 index 0000000..b499e95 --- /dev/null +++ b/ansible/requirements.yml @@ -0,0 +1,10 @@ +--- + +collections: + + - community.docker + + - name: amolofos.ansible_collection_workstation + type: git + source: "https://github.com/amolofos/ansible_collection_workstation.git" + version: "feature/re-structure" diff --git a/ansible/roles/admin_cronjob/defaults/main.yml b/ansible/roles/admin_cronjob/defaults/main.yml deleted file mode 100644 index 18d71fb..0000000 --- a/ansible/roles/admin_cronjob/defaults/main.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- - -admin_cron: - name: "Automated workstation setup" - minute: "0" - hour: "13" - job: "/home/admin/scripts/admin-cronjob.sh > /home/admin/logs/admin-cronjob.log.`date \"+\\%Y-\\%m-\\%d_\\%H\"` 2>&1" - - directory_tmp: "/home/admin/automated-workstation-setup/" - - branch: "main" - - repository: "https://github.com/amolofos/automated-workstation-setup.git" - - users_to_notify: [] - - notify_message_success: "Automated workstation setup has been successful." - notify_message_failure: "Automated workstation setup has failed." diff --git a/ansible/roles/admin_cronjob/tasks/debian.yml b/ansible/roles/admin_cronjob/tasks/debian.yml deleted file mode 100644 index 28cc444..0000000 --- a/ansible/roles/admin_cronjob/tasks/debian.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- - -- name: Create /home/admin/scripts directory - ansible.builtin.file: - path: /home/admin/scripts - state: directory - owner: "admin" - group: "admin" - mode: "700" - -- name: Install cronjob script - ansible.builtin.template: - src: "admin-cronjob.sh.j2" - dest: "/home/admin/scripts/admin-cronjob.sh" - owner: "admin" - group: "admin" - mode: "700" - backup: false - -- name: Install crontab - ansible.builtin.cron: - hour: "{{ admin_cron.hour }}" - job: "{{ admin_cron.job }}" - minute: "{{ admin_cron.minute }}" - name: "{{ admin_cron.name }}" - user: "admin" diff --git a/ansible/roles/admin_cronjob/tasks/main.yml b/ansible/roles/admin_cronjob/tasks/main.yml deleted file mode 100644 index 61bc9fc..0000000 --- a/ansible/roles/admin_cronjob/tasks/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -- include: debian.yml - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/admin_cronjob/templates/admin-cronjob.sh.j2 b/ansible/roles/admin_cronjob/templates/admin-cronjob.sh.j2 deleted file mode 100644 index e864ac2..0000000 --- a/ansible/roles/admin_cronjob/templates/admin-cronjob.sh.j2 +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# It is expected to be run under admin user. -# -set -ueo pipefail - -REPOSITORY_BRANCH=${REPOSITORY_BRANCH:-{{ admin_cron.branch }}} -REPOSITORY=${REPOSITORY:-{{ admin_cron.repository }}} - -log() { - echo "`date +"%Y-%m-%d %H:%M:%S"`: $1" -} - -rm -rf {{ admin_cron.directory_tmp }} && \ - git clone --quiet --branch $REPOSITORY_BRANCH $REPOSITORY --depth 1 {{ admin_cron.directory_tmp }} && \ - cd {{ admin_cron.directory_tmp }} && \ - ./scripts/scheduled-debian.sh && \ - cd $HOME && \ - rm -rf {{ admin_cron.directory_tmp }} - -{% if admin_cron.users_to_notify is defined and admin_cron.users_to_notify | length > 0 %} -if [ "$?" -eq "0" ]; then -{% for user in admin_cron.users_to_notify %} - sudo -iu {{ user }} sh -c "notify-send -i face-wink '{{ admin_cron.name }}' '{{ admin_cron.notify_message_success }}'" -{% endfor %} -else -{% for user in admin_cron.users_to_notify %} - sudo -iu {{ user }} sh -c "notify-send -t 0 -i face-wink '{{ admin_cron.name }}' '{{ admin_cron.notify_message_failure }}'" -{% endfor %} -fi -{% endif %} diff --git a/ansible/roles/settings/application/defaults/main.yml b/ansible/roles/settings/application/defaults/main.yml deleted file mode 100644 index adab5a3..0000000 --- a/ansible/roles/settings/application/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- - -are_we_in_docker: false diff --git a/ansible/roles/settings/application/tasks/dconf.yml b/ansible/roles/settings/application/tasks/dconf.yml deleted file mode 100644 index 09170d6..0000000 --- a/ansible/roles/settings/application/tasks/dconf.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -# application_settings: -# dconf: -# debian: -# - { "key": "com/ubuntu/sound/allow-amplified-volume", "value": "false" } -- name: Setup dconf settings for Debian system - dconf: - key: "{{ dconf.key }}" - value: "{{ dconf.value }}" - state: "present" - loop: "{{ settings_application.dconf.debian | default([]) }}" - loop_control: - loop_var: dconf - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/settings/application/tasks/dot-files.yml b/ansible/roles/settings/application/tasks/dot-files.yml deleted file mode 100644 index 730fff1..0000000 --- a/ansible/roles/settings/application/tasks/dot-files.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- - -# settings_application: -# dot_files: -# debian: -# - user: dkafetzi -# git_url: "" -# templates: -# - { "src": "admin-sudoers.d.j2, "dest": "/etc/sudoers.d/99-admin-passwordless", "mode": '0440', "validate": "/usr/sbin/visudo -cf %s" } - -- name: Create user directories - ansible.builtin.file: - path: "{{ dir.1.path }}" - owner: "{{ dir.1.owner | default(dir.0.user) }}" - group: "{{ dir.1.group | default(dir.0.user) }}" - state: directory - mode: "{{ dir.1.mode | default('0755') }}" - loop: "{{ settings_application.dot_files.debian | default([]) | subelements('directories', skip_missing=True) }}" - loop_control: - loop_var: dir - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Setup user dot files - ansible.builtin.template: - src: "{{ dot_file.1.src }}" - dest: "{{ dot_file.1.dest }}" - owner: "{{ dot_file.1.owner | default(dot_file.0.user) }}" - group: "{{ dot_file.1.group | default(dot_file.0.user) }}" - mode: "{{ dot_file.1.mode | default('0755') }}" - validate: "{{ dot_file.1.validate | default('') }}" - backup: false - vars: - user: "{{ dot_file.0.user }}" - loop: "{{ settings_application.dot_files.debian | default([]) | subelements('templates', skip_missing=True) }}" - loop_control: - loop_var: dot_file - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/settings/application/tasks/gsettings.yml b/ansible/roles/settings/application/tasks/gsettings.yml deleted file mode 100644 index 7d222b5..0000000 --- a/ansible/roles/settings/application/tasks/gsettings.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- - -# application_settings: -# gsettings: -# debian: -# - user: dkafetzi -# settings: -# - { "schema": "org.gnome.shell", "key": "favorite-apps", "value": "['code.desktop']" } -- name: Setup application settings for Debian system # noqa fqcn-builtins - register: gsettings_out - become: true - become_user: "{{ gsettings.0.user }}" - shell: | - export DISPLAY=:0.0; - existingSettings=`gsettings get {{ gsettings.1.schema }} {{ gsettings.1.key }}`; - if [ "${existingSettings}" != "{{ gsettings.1.value }}" ]; then - gsettings set {{ gsettings.1.schema }} {{ gsettings.1.key }} "{{ gsettings.1.value }}"; - echo 'Setting applied.'; - fi - args: - executable: /bin/bash - warn: false - loop: "{{ settings_application.gsettings.debian | default([]) | subelements('settings', skip_missing=True) }}" - loop_control: - loop_var: gsettings - failed_when: - - gsettings_out.module_stderr | default(gsettings_out.stderr) | length > 0 - - "'No such schema' not in gsettings_out.module_stderr | default(gsettings_out.stderr)" - # Hack to workaround the dbus not running by default in docker. - - "'Error spawning command line' in gsettings_out.module_stderr | default(gsettings_out.stderr) and not are_we_in_docker" - changed_when: - - gsettings_out.module_stderr | default(gsettings_out.stderr) | length == 0 - - "'Setting applied.' in gsettings_out.module_stdout | default(gsettings_out.stdout)" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/settings/application/tasks/main.yml b/ansible/roles/settings/application/tasks/main.yml deleted file mode 100644 index fa15f2e..0000000 --- a/ansible/roles/settings/application/tasks/main.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- - -- name: Applying gsettings - include: gsettings.yml - when: - - settings_application.gsettings | length > 0 - -- name: Applying dconf - include: dconf.yml - when: - - settings_application.dconf | length > 0 - -- name: Creating dot-files - include: dot-files.yml - when: - - settings_application.dot_files | length > 0 - -- name: Handling vscode settings - include: vscode.yml - when: - - settings_application.vscode | length > 0 diff --git a/ansible/roles/settings/application/tasks/vscode.yml b/ansible/roles/settings/application/tasks/vscode.yml deleted file mode 100644 index 66861fd..0000000 --- a/ansible/roles/settings/application/tasks/vscode.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -# settings_application: -# vscode: -# - user: dkafetzi -# extentions: [] -- name: Install vscode extentions # noqa fqcn-builtins - register: vscode_out - become: true - become_user: "{{ settings.0.user }}" - shell: | - code --install-extension {{ settings.1 }} --force - args: - executable: /bin/bash - warn: false - loop: "{{ settings_application.vscode | default([]) | subelements('extentions', skip_missing=True) }}" - loop_control: - loop_var: settings - changed_when: - - "'is already installed.' not in vscode_out.stdout or 'was successfully installed' in vscode_out.stdout" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - - not are_we_in_docker diff --git a/ansible/roles/settings/application/templates/10-wakeup.rules.j2 b/ansible/roles/settings/application/templates/10-wakeup.rules.j2 deleted file mode 100644 index 0a22316..0000000 --- a/ansible/roles/settings/application/templates/10-wakeup.rules.j2 +++ /dev/null @@ -1,28 +0,0 @@ -# {{ ansible_managed }} -# https://askubuntu.com/questions/899923/how-to-wake-from-suspend-with-usb-keyboard-16-04-lts - -# ----------------------------------------------------------------------------- -# Wake up on usb mouse - -# Initial script -# ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52f" RUN+="/bin/sh -c 'echo enabled > /sys/bus/usb/devices/1-3/power/wakeup'" - -# Latest script -# 1. Check current setup -# grep . /sys/bus/usb/devices/*/power/wakeup -# 2. Add the commands below in here -# 3. Restart -# systemctl restart udev.service -# udevadm trigger - -# Enable wakeup on ALL USB hubs (0-99) -KERNEL=="usb[0-9]|usb[0-9][0-9]", SUBSYSTEM=="usb", DRIVER=="usb", ATTR{power/wakeup}="enabled" - -# Enable wakeup for all keyboards -# Keyboards are HID class 3 protocol 1 devices. -SUBSYSTEM=="usb", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceProtocol}=="01", ATTR{../power/wakeup}="enabled" - -# Enable wakeup for all mice (button click, not movement) -# Mice are HID class 3 protocol 2 devices. -SUBSYSTEM=="usb", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceProtocol}=="02", ATTR{../power/wakeup}="enabled" -# ----------------------------------------------------------------------------- diff --git a/ansible/roles/settings/application/templates/bash_profile.dkafetzi.j2 b/ansible/roles/settings/application/templates/bash_profile.dkafetzi.j2 deleted file mode 100644 index 74033aa..0000000 --- a/ansible/roles/settings/application/templates/bash_profile.dkafetzi.j2 +++ /dev/null @@ -1,11 +0,0 @@ -# {{ ansible_managed }} - -if [ -f ~/.bashrc ]; then - source ~/.bashrc -fi - -if [ -d ~/.bashrc.d ]; then - for file in $(find "$HOME/.bashrc.d/" -type f -name "*.bashrc"); do - source "$file" - done -fi diff --git a/ansible/roles/settings/application/templates/bashrc_aliases.dkafetzi.j2 b/ansible/roles/settings/application/templates/bashrc_aliases.dkafetzi.j2 deleted file mode 100644 index 2c9c6df..0000000 --- a/ansible/roles/settings/application/templates/bashrc_aliases.dkafetzi.j2 +++ /dev/null @@ -1,3 +0,0 @@ -# {{ ansible_managed }} - -alias grep='grep --color=auto' diff --git a/ansible/roles/settings/application/templates/bashrc_autocompletion.dkafetzi.j2 b/ansible/roles/settings/application/templates/bashrc_autocompletion.dkafetzi.j2 deleted file mode 100644 index d15b5f4..0000000 --- a/ansible/roles/settings/application/templates/bashrc_autocompletion.dkafetzi.j2 +++ /dev/null @@ -1,11 +0,0 @@ -# {{ ansible_managed }} - -# SSH auto-completion based on entries in known_hosts. -if [[ -e ~/.ssh/known_hosts ]]; then - complete -o default -W "$(cat ~/.ssh/known_hosts | sed 's/[, ].*//' | sort | uniq | grep -v '[0-9]')" ssh scp sftp -fi - -# bash-completion -if [[ -e /usr/share/bash-completion/bash_completion ]]; then - source /usr/share/bash-completion/bash_completion -fi diff --git a/ansible/roles/settings/application/templates/bashrc_common.dkafetzi.j2 b/ansible/roles/settings/application/templates/bashrc_common.dkafetzi.j2 deleted file mode 100644 index 91c7170..0000000 --- a/ansible/roles/settings/application/templates/bashrc_common.dkafetzi.j2 +++ /dev/null @@ -1,25 +0,0 @@ -# {{ ansible_managed }} - -# Duplicate entries will be erased (leaving the most recent entry). -export HISTCONTROL="erasedups" - -# Give history timestamps. -export HISTTIMEFORMAT="[%F %T] " - -# Lots o' history. -export HISTSIZE=100000 -export HISTFILESIZE=2000000 -shopt -s histappend - -# COLOURS! YAAAY! -export TERM=xterm-256color - -# Case-insensitive globbing (used in pathname expansion) -shopt -s nocaseglob - -# Check the window size after each command and, if necessary, -# update the values of LINES and COLUMNS. -shopt -s checkwinsize - -# Prevent less from clearing the screen while still showing colors. -export LESS=-XR diff --git a/ansible/roles/settings/application/templates/gitconfig.dkafetzi.j2 b/ansible/roles/settings/application/templates/gitconfig.dkafetzi.j2 deleted file mode 100644 index d809d60..0000000 --- a/ansible/roles/settings/application/templates/gitconfig.dkafetzi.j2 +++ /dev/null @@ -1,41 +0,0 @@ -[user] - name = {{ users[user].name | default('') }} - email = {{ users[user].email | default('') }} -[core] - autocrlf = input - whitespace = fix,space-before-tab,tab-in-indent,trailing-space - excludesfile = ~/.gitignore_global - editor = /bin/vim -[apply] - whitespace = fix -[alias] - br = branch - ci = commit - co = checkout - df = diff - st = status -[branch "master"] - remote = origin - merge = refs/heads/master -[color] - ui = auto - diff = auto - status = auto - branch = auto -[color "branch"] - current = yellow reverse - local = yellow - remote = green -[color "diff"] - meta = yellow bold - frag = magenta bold - old = red bold - new = green bold -[color "status"] - added = yellow - changed = green - untracked = cyan -[push] - default = simple -[merge] - log = true diff --git a/ansible/roles/settings/application/templates/inputrc.dkafetzi.j2 b/ansible/roles/settings/application/templates/inputrc.dkafetzi.j2 deleted file mode 100644 index 37b7577..0000000 --- a/ansible/roles/settings/application/templates/inputrc.dkafetzi.j2 +++ /dev/null @@ -1,12 +0,0 @@ -# {{ ansible_managed }} - -# do not bell on tab-completion -# set bell-style none - -# allow the use of the Home/End keys -"\e[1~": beginning-of-line -"\e[4~": end-of-line - -# alternate mappings for "page up" and "page down" to search the history -"\e[5~": history-search-backward -"\e[6~": history-search-forward diff --git a/ansible/roles/settings/application/templates/neovim.init.vim.dkafetzi.j2 b/ansible/roles/settings/application/templates/neovim.init.vim.dkafetzi.j2 deleted file mode 100644 index d808780..0000000 --- a/ansible/roles/settings/application/templates/neovim.init.vim.dkafetzi.j2 +++ /dev/null @@ -1,12 +0,0 @@ -" {{ ansible_managed }} - -set autoindent " indent a new line the same amount as the line just typed - -set backupdir=~/.cache/vim " Directory to store backup files. - -set tabstop=2 " number of columns occupied by a tab -set ttyfast " Speed up scrolling in Vim - -set visualbell - -set wildmode=longest,list " get bash-like tab completions diff --git a/ansible/roles/settings/application/templates/profile.d.golang.j2 b/ansible/roles/settings/application/templates/profile.d.golang.j2 deleted file mode 100644 index 2a6bea6..0000000 --- a/ansible/roles/settings/application/templates/profile.d.golang.j2 +++ /dev/null @@ -1,6 +0,0 @@ -# {{ ansible_managed }} - -export GOPATH=$HOME/go - -export PATH=$PATH:/usr/local/go/bin -export PATH=$GOPATH/bin:$PATH diff --git a/ansible/roles/settings/application/templates/profile.dkafetzi.j2 b/ansible/roles/settings/application/templates/profile.dkafetzi.j2 deleted file mode 100644 index d82686f..0000000 --- a/ansible/roles/settings/application/templates/profile.dkafetzi.j2 +++ /dev/null @@ -1,4 +0,0 @@ -# {{ ansible_managed }} - -export GOPATH=~/workspace/go -export PATH=$GOPATH/bin:$PATH diff --git a/ansible/roles/settings/application/templates/ssh.config.dkafetzi.j2 b/ansible/roles/settings/application/templates/ssh.config.dkafetzi.j2 deleted file mode 100644 index 287e7b3..0000000 --- a/ansible/roles/settings/application/templates/ssh.config.dkafetzi.j2 +++ /dev/null @@ -1,16 +0,0 @@ -# {{ ansible_managed }} - -Host * - -# Forward ssh agent to the remote machine. -ForwardAgent yes - -# Automatically add all common hosts to the host file as they are connected to. -StrictHostKeyChecking no - -# Allow MacOS to use the keychain for SSH key passphrases -IgnoreUnknown UseKeychain -Host * - UseKeychain yes - AddKeysToAgent yes - IdentityFile ~/.ssh/id_rsa diff --git a/ansible/roles/settings/application/templates/sudoers.d.admin.j2 b/ansible/roles/settings/application/templates/sudoers.d.admin.j2 deleted file mode 100644 index 5621f13..0000000 --- a/ansible/roles/settings/application/templates/sudoers.d.admin.j2 +++ /dev/null @@ -1,4 +0,0 @@ -# {{ ansible_managed }} - -# Give admin group passwordless sudo. -%admin ALL=(ALL) NOPASSWD:ALL diff --git a/ansible/roles/settings/application/templates/vimrc.dkafetzi.j2 b/ansible/roles/settings/application/templates/vimrc.dkafetzi.j2 deleted file mode 100644 index a877a9d..0000000 --- a/ansible/roles/settings/application/templates/vimrc.dkafetzi.j2 +++ /dev/null @@ -1,3 +0,0 @@ -# {{ ansible_managed }} - -set visualbell diff --git a/ansible/roles/settings/application/templates/vscode.settings.json.dkafetzi.j2 b/ansible/roles/settings/application/templates/vscode.settings.json.dkafetzi.j2 deleted file mode 100644 index f6aa5db..0000000 --- a/ansible/roles/settings/application/templates/vscode.settings.json.dkafetzi.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{ - "comment" : "{{ ansible_managed }}", - - "editor.tabSize" : 2, - "explorer.confirmDelete" : false, - "files.insertFinalNewline" : true, - "files.trimFinalNewlines" : true, - "files.trimTrailingWhitespace" : true -} diff --git a/ansible/roles/settings/user/tasks/main.yml b/ansible/roles/settings/user/tasks/main.yml deleted file mode 100644 index c26d25f..0000000 --- a/ansible/roles/settings/user/tasks/main.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -# settings_user: -# groups: -# dkafetzi: -# - docker -- name: Configure user groups - ansible.builtin.user: - name: "{{ settings.key }}" - groups: "{{ settings.value | join(',') }}" - append: true - loop: "{{ query('dict', settings_user.groups | default({})) | list }}" - loop_control: - loop_var: settings - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software-k8s-toolbox/Readme.md b/ansible/roles/software-k8s-toolbox/Readme.md deleted file mode 100644 index 7813e2c..0000000 --- a/ansible/roles/software-k8s-toolbox/Readme.md +++ /dev/null @@ -1,2 +0,0 @@ -These roles have been copied over from https://github.com/Pandemonium1986/ansible-collection-k8s-toolbox -and adjusted accordingly. diff --git a/ansible/roles/software-k8s-toolbox/helm/LICENSE b/ansible/roles/software-k8s-toolbox/helm/LICENSE deleted file mode 100644 index df279d2..0000000 --- a/ansible/roles/software-k8s-toolbox/helm/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Michael Maffait - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/ansible/roles/software-k8s-toolbox/helm/README.md b/ansible/roles/software-k8s-toolbox/helm/README.md deleted file mode 100644 index d50bff1..0000000 --- a/ansible/roles/software-k8s-toolbox/helm/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Ansible role : helm - -* * * - -**Disclaimer** -All contributions made directly in this repository will be deleted by force push. If you want to contribute, go to [ansible-collection-k8s-toolbox](https://github.com/Pandemonium1986/ansible-collection-k8s-toolbox) - -* * * - -![Ansible Role](https://img.shields.io/ansible/role/51080?logo=ansible) -![Github pipeline status](https://github.com/Pandemonium1986/ansible-role-helm/workflows/Molecule:%20Github%20actions%20pipeline/badge.svg) -![GitHub release](https://img.shields.io/github/release/Pandemonium1986/ansible-role-helm.svg?logo=github) -![Github license](https://img.shields.io/github/license/Pandemonium1986/ansible-role-helm.svg?logo=github) -![Ansible Quality Score](https://img.shields.io/ansible/quality/51080?logo=ansible) - -Install and configure helm from helm registry. - -## Requirements - -This role is self contained and install helm for debian, ubuntu, linux mint, centos. - -## Role Variables - -From defaults/main.yml : - -```yaml -helm_cache_path: "/var/cache/github" -helm_installation_path: "/opt/github/helm" -helm_checksum: "sha256:b664632683c36446deeb85c406871590d879491e3de18978b426769e43a1e82c" -helm_version: "v3.3.4" -``` - -## Example Playbook - -```yaml -- name: helm installation - hosts: all - become: true - tasks: - - import_role: - name: pandemonium1986.helm -``` - -## Versioning - -We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/Pandemonium1986/ansible-role-helm/tags). - -## Authors - -- **Michael Maffait** - _Initial work_ - [Pandemonium1986](https://github.com/Pandemonium1986) - -See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. - -## License - -This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details diff --git a/ansible/roles/software-k8s-toolbox/helm/defaults/main.yml b/ansible/roles/software-k8s-toolbox/helm/defaults/main.yml deleted file mode 100644 index 09abfb1..0000000 --- a/ansible/roles/software-k8s-toolbox/helm/defaults/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -are_we_in_docker: false - -# https://github.com/helm/helm -helm_cache_path: "/var/cache/github" -helm_installation_path: "/opt/github/helm" -helm_checksum: "" -helm_version: "v3.10.1" diff --git a/ansible/roles/software-k8s-toolbox/helm/tasks/main.yml b/ansible/roles/software-k8s-toolbox/helm/tasks/main.yml deleted file mode 100644 index 17baa02..0000000 --- a/ansible/roles/software-k8s-toolbox/helm/tasks/main.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -- name: Ensure helm directories are created - file: - path: "{{ item }}" - state: directory - mode: "0755" - loop: - - "{{ helm_cache_path }}" - - "{{ helm_installation_path }}" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Ensure helm is installed - get_url: - url: "{{ source_url }}/{{ asset_name }}" - dest: "{{ helm_cache_path }}" - checksum: "{{ helm_checksum }}" - mode: "0755" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Unarchive helm archive into helm_installation_path - unarchive: - src: "{{ helm_cache_path }}/{{ asset_name }}" - dest: "{{ helm_installation_path }}" - remote_src: true - mode: "0755" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Ensure helm link is created - file: - src: "{{ helm_installation_path }}/{{ platform_name }}/{{ binary_name }}" - dest: "/usr/local/bin/{{ binary_name }}" - state: link - force: true - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software-k8s-toolbox/helm/vars/main.yml b/ansible/roles/software-k8s-toolbox/helm/vars/main.yml deleted file mode 100644 index 89328ad..0000000 --- a/ansible/roles/software-k8s-toolbox/helm/vars/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -source_url: "https://get.helm.sh" -platform_name: "linux-amd64" -asset_name: "helm-{{ helm_version }}-{{ platform_name }}.tar.gz" -binary_name: "helm" diff --git a/ansible/roles/software-k8s-toolbox/k9s/LICENSE b/ansible/roles/software-k8s-toolbox/k9s/LICENSE deleted file mode 100644 index df279d2..0000000 --- a/ansible/roles/software-k8s-toolbox/k9s/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Michael Maffait - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/ansible/roles/software-k8s-toolbox/k9s/README.md b/ansible/roles/software-k8s-toolbox/k9s/README.md deleted file mode 100644 index 0d5c35e..0000000 --- a/ansible/roles/software-k8s-toolbox/k9s/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Ansible role : k9s - -* * * - -**Disclaimer** -All contributions made directly in this repository will be deleted by force push. If you want to contribute, go to [ansible-collection-k8s-toolbox](https://github.com/Pandemonium1986/ansible-collection-k8s-toolbox) - -* * * - -![Ansible Role](https://img.shields.io/ansible/role/51049?logo=ansible) -![Github pipeline status](https://github.com/Pandemonium1986/ansible-role-k9s/workflows/Molecule:%20Github%20actions%20pipeline/badge.svg) -![GitHub release](https://img.shields.io/github/release/Pandemonium1986/ansible-role-k9s.svg?logo=github) -![Github license](https://img.shields.io/github/license/Pandemonium1986/ansible-role-k9s.svg?logo=github) -![Ansible Quality Score](https://img.shields.io/ansible/quality/51049?logo=ansible) - -Install and configure k9s from github repository. - -## Requirements - -This role is self contained and install k9s for debian, ubuntu, linux mint, centos. - -## Role Variables - -From defaults/main.yml : - -```yaml -k9s_cache_path: "/var/cache/github" -k9s_installation_path: "/opt/github/k9s" -k9s_checksum: "sha256:42d8aef6b839a9bc60de29d2461521596ce2d1f66347dbf5196983229cfeafd2" -k9s_version: "v0.22.1" -``` - -## Example Playbook - -```yaml -- name: k9s installation - hosts: all - become: true - tasks: - - import_role: - name: pandemonium1986.k9s -``` - -## Versioning - -We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/Pandemonium1986/ansible-role-k9s/tags). - -## Authors - -- **Michael Maffait** - _Initial work_ - [Pandemonium1986](https://github.com/Pandemonium1986) - -See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. - -## License - -This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details diff --git a/ansible/roles/software-k8s-toolbox/k9s/defaults/main.yml b/ansible/roles/software-k8s-toolbox/k9s/defaults/main.yml deleted file mode 100644 index 609fb91..0000000 --- a/ansible/roles/software-k8s-toolbox/k9s/defaults/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# https://github.com/derailed/k9s -k9s_cache_path: "/var/cache/github" -k9s_installation_path: "/opt/github/k9s" -k9s_checksum: "" -k9s_version: "v0.26.7" diff --git a/ansible/roles/software-k8s-toolbox/k9s/tasks/main.yml b/ansible/roles/software-k8s-toolbox/k9s/tasks/main.yml deleted file mode 100644 index 4d80729..0000000 --- a/ansible/roles/software-k8s-toolbox/k9s/tasks/main.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- name: Ensure k9s directories are created - file: - path: "{{ item }}" - state: directory - mode: "0755" - loop: - - "{{ k9s_cache_path }}" - - "{{ k9s_installation_path }}" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Ensure k9s is installed - get_url: - url: "{{ source_url }}/{{ github_namespace }}/releases/download/{{ k9s_version }}/{{ asset_name }}" - dest: "{{ k9s_cache_path }}" - checksum: "{{ k9s_checksum }}" - mode: "0755" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Unarchive k9s archive into k9s_installation_path - unarchive: - src: "{{ k9s_cache_path }}/{{ asset_name }}" - dest: "{{ k9s_installation_path }}" - remote_src: true - mode: "0755" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Ensure k9s link is created - file: - src: "{{ k9s_installation_path }}/{{ binary_name }}" - dest: "/usr/local/bin/{{ binary_name }}" - state: link - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software-k8s-toolbox/k9s/vars/main.yml b/ansible/roles/software-k8s-toolbox/k9s/vars/main.yml deleted file mode 100644 index ed6af89..0000000 --- a/ansible/roles/software-k8s-toolbox/k9s/vars/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -source_url: "https://github.com" -github_namespace: "derailed/k9s" -asset_name: "k9s_Linux_x86_64.tar.gz" -binary_name: "k9s" diff --git a/ansible/roles/software-k8s-toolbox/kubectl/LICENSE b/ansible/roles/software-k8s-toolbox/kubectl/LICENSE deleted file mode 100644 index df279d2..0000000 --- a/ansible/roles/software-k8s-toolbox/kubectl/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Michael Maffait - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/ansible/roles/software-k8s-toolbox/kubectl/README.md b/ansible/roles/software-k8s-toolbox/kubectl/README.md deleted file mode 100644 index 4a0b25d..0000000 --- a/ansible/roles/software-k8s-toolbox/kubectl/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# Ansible role : kubectl - -* * * - -**Disclaimer** -All contributions made directly in this repository will be deleted by force push. If you want to contribute, go to [ansible-collection-k8s-toolbox](https://github.com/Pandemonium1986/ansible-collection-k8s-toolbox) - -* * * - -![Ansible Role](https://img.shields.io/ansible/role/50928?logo=ansible) -![Github pipeline status](https://github.com/Pandemonium1986/ansible-role-kubectl/workflows/Molecule:%20Github%20actions%20pipeline/badge.svg) -![GitHub release](https://img.shields.io/github/release/Pandemonium1986/ansible-role-kubectl.svg?logo=github) -![Github license](https://img.shields.io/github/license/Pandemonium1986/ansible-role-kubectl.svg?logo=github) -![Ansible Quality Score](https://img.shields.io/ansible/quality/50928?logo=ansible) - -Install and configure kubectl. - -## Requirements - -This role is self contained and install kubectl via package manager for debian, ubuntu, linux mint, centos. - -## Role Variables - -From defaults/main.yml : - -```yaml -kubectl_version: "1.20.0" -``` - -## Example Playbook - -```yaml -- name: kubectl installation - hosts: all - become: true - tasks: - - import_role: - name: pandemonium1986.kubectl -``` - -## Versioning - -We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/Pandemonium1986/ansible-role-kubectl/tags). - -## Authors - -- **Michael Maffait** - _Initial work_ - [Pandemonium1986](https://github.com/Pandemonium1986) - -See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. - -## License - -This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details diff --git a/ansible/roles/software-k8s-toolbox/kubectl/defaults/main.yml b/ansible/roles/software-k8s-toolbox/kubectl/defaults/main.yml deleted file mode 100644 index 1d2eff8..0000000 --- a/ansible/roles/software-k8s-toolbox/kubectl/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -# https://github.com/kubernetes/kubectl -kubectl_version: "1.25.3" diff --git a/ansible/roles/software-k8s-toolbox/kubectl/tasks/main.yml b/ansible/roles/software-k8s-toolbox/kubectl/tasks/main.yml deleted file mode 100644 index 7be3608..0000000 --- a/ansible/roles/software-k8s-toolbox/kubectl/tasks/main.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- name: Ensure kubectl is installed - apt: - name: "kubectl={{ kubectl_version }}-00" - update_cache: true - state: present - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software-k8s-toolbox/kubectx/LICENSE b/ansible/roles/software-k8s-toolbox/kubectx/LICENSE deleted file mode 100644 index df279d2..0000000 --- a/ansible/roles/software-k8s-toolbox/kubectx/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Michael Maffait - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/ansible/roles/software-k8s-toolbox/kubectx/README.md b/ansible/roles/software-k8s-toolbox/kubectx/README.md deleted file mode 100644 index 5b01ddb..0000000 --- a/ansible/roles/software-k8s-toolbox/kubectx/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# Ansible role : kubectx - -* * * - -**Disclaimer** -All contributions made directly in this repository will be deleted by force push. If you want to contribute, go to [ansible-collection-k8s-toolbox](https://github.com/Pandemonium1986/ansible-collection-k8s-toolbox) - -* * * - -![Ansible Role](https://img.shields.io/ansible/role/51012?logo=ansible) -![Github pipeline status](https://github.com/Pandemonium1986/ansible-role-kubectx/workflows/Molecule:%20Github%20actions%20pipeline/badge.svg) -![GitHub release](https://img.shields.io/github/release/Pandemonium1986/ansible-role-kubectx.svg?logo=github) -![Github license](https://img.shields.io/github/license/Pandemonium1986/ansible-role-kubectx.svg?logo=github) -![Ansible Quality Score](https://img.shields.io/ansible/quality/51012?logo=ansible) - -Installs kubectx and kubens from github repository. - -## Requirements - -This role is not self contained. He requires pandemonium1986.kubectl to work correctly. - -```sh - ansible-galaxy install -f pandemonium1986.kubectl -``` - -## Role Variables - -From defaults/main.yml : - -```yaml -kubectx_installation_path: "/opt/github/kubectx" -kubectx_version: "master" -``` - -## Example Playbook - -```yaml -- name: kubectx installation - hosts: all - become: true - tasks: - - import_role: - name: pandemonium1986.kubectx -``` - -## Versioning - -We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/Pandemonium1986/ansible-role-kubectx/tags). - -## Authors - -- **Michael Maffait** - _Initial work_ - [Pandemonium1986](https://github.com/Pandemonium1986) - -See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. - -## License - -This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details diff --git a/ansible/roles/software-k8s-toolbox/kubectx/defaults/main.yml b/ansible/roles/software-k8s-toolbox/kubectx/defaults/main.yml deleted file mode 100644 index 919d5c4..0000000 --- a/ansible/roles/software-k8s-toolbox/kubectx/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -# https://github.com/ahmetb/kubectx -kubectx_installation_path: "/opt/github/kubectx" -kubectx_version: "master" diff --git a/ansible/roles/software-k8s-toolbox/kubectx/tasks/main.yml b/ansible/roles/software-k8s-toolbox/kubectx/tasks/main.yml deleted file mode 100644 index 1541ed1..0000000 --- a/ansible/roles/software-k8s-toolbox/kubectx/tasks/main.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- - -- name: Ensure kubectx repository is cloned from GitHub - git: - repo: "{{ source_url }}/{{ github_namespace }}" - dest: "{{ kubectx_installation_path }}" - version: "{{ kubectx_version }}" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Ensure kubectx and kubens links are created - file: - src: "{{ kubectx_installation_path }}/{{ item }}" - dest: "/usr/local/bin/{{ item }}" - state: link - loop: "{{ asset_name }}" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software-k8s-toolbox/kubectx/vars/main.yml b/ansible/roles/software-k8s-toolbox/kubectx/vars/main.yml deleted file mode 100644 index d802d56..0000000 --- a/ansible/roles/software-k8s-toolbox/kubectx/vars/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -source_url: "https://github.com" -github_namespace: "ahmetb/kubectx" -asset_name: - - kubens - - kubectx diff --git a/ansible/roles/software-k8s-toolbox/minikube/LICENSE b/ansible/roles/software-k8s-toolbox/minikube/LICENSE deleted file mode 100644 index ea081f4..0000000 --- a/ansible/roles/software-k8s-toolbox/minikube/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Michael Maffait - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/ansible/roles/software-k8s-toolbox/minikube/README.md b/ansible/roles/software-k8s-toolbox/minikube/README.md deleted file mode 100644 index d5b3ffe..0000000 --- a/ansible/roles/software-k8s-toolbox/minikube/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# Ansible role : minikube - -* * * - -**Disclaimer** -All contributions made directly in this repository will be deleted by force push. If you want to contribute, go to [ansible-collection-k8s-toolbox](https://github.com/Pandemonium1986/ansible-collection-k8s-toolbox) - -* * * - -![Ansible Role](https://img.shields.io/ansible/role/50991?logo=ansible) -![Github pipeline status](https://github.com/Pandemonium1986/ansible-role-minikube/workflows/Molecule:%20Github%20actions%20pipeline/badge.svg) -![GitHub release](https://img.shields.io/github/release/Pandemonium1986/ansible-role-minikube.svg?logo=github) -![Github license](https://img.shields.io/github/license/Pandemonium1986/ansible-role-minikube.svg?logo=github) -![Ansible Quality Score](https://img.shields.io/ansible/quality/50991?logo=ansible) - -Install and configure minikube. - -## Requirements - -This role is self contained and install minikube via package manager for debian, ubuntu, linux mint, centos. - -## Role Variables - -From defaults/main.yml : - -```yaml -minikube_version: "1.17.1" -``` - -## Example Playbook - -```yaml -- name: minikube installation - hosts: all - become: true - tasks: - - import_role: - name: pandemonium1986.minikube -``` - -## Versioning - -We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/Pandemonium1986/ansible-role-minikube/tags). - -## Authors - -- **Michael Maffait** - _Initial work_ - [Pandemonium1986](https://github.com/Pandemonium1986) - -See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. - -## License - -This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details diff --git a/ansible/roles/software-k8s-toolbox/minikube/defaults/main.yml b/ansible/roles/software-k8s-toolbox/minikube/defaults/main.yml deleted file mode 100644 index 4db8bae..0000000 --- a/ansible/roles/software-k8s-toolbox/minikube/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -# https://github.com/kubernetes/minikube -minikube_version: "1.28.0" diff --git a/ansible/roles/software-k8s-toolbox/minikube/tasks/main.yml b/ansible/roles/software-k8s-toolbox/minikube/tasks/main.yml deleted file mode 100644 index f8ebcf3..0000000 --- a/ansible/roles/software-k8s-toolbox/minikube/tasks/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: Ensure minikube is installed - apt: - deb: "https://storage.googleapis.com/minikube/releases/v{{ minikube_version }}/minikube_{{ minikube_version }}-0_amd64.deb" - state: present - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software-k8s-toolbox/stern/LICENSE b/ansible/roles/software-k8s-toolbox/stern/LICENSE deleted file mode 100644 index df279d2..0000000 --- a/ansible/roles/software-k8s-toolbox/stern/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Michael Maffait - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/ansible/roles/software-k8s-toolbox/stern/README.md b/ansible/roles/software-k8s-toolbox/stern/README.md deleted file mode 100644 index 8008691..0000000 --- a/ansible/roles/software-k8s-toolbox/stern/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# Ansible role : stern - -* * * - -**Disclaimer** -All contributions made directly in this repository will be deleted by force push. If you want to contribute, go to [ansible-collection-k8s-toolbox](https://github.com/Pandemonium1986/ansible-collection-k8s-toolbox) - -* * * - -![Ansible Role](https://img.shields.io/ansible/role/51037?logo=ansible) -![Github pipeline status](https://github.com/Pandemonium1986/ansible-role-stern/workflows/Molecule:%20Github%20actions%20pipeline/badge.svg) -![GitHub release](https://img.shields.io/github/release/Pandemonium1986/ansible-role-stern.svg?logo=github) -![Github license](https://img.shields.io/github/license/Pandemonium1986/ansible-role-stern.svg?logo=github) -![Ansible Quality Score](https://img.shields.io/ansible/quality/51037?logo=ansible) - -Install and configure stern from github repository. - -## Requirements - -This role is self contained and install stern for debian, ubuntu, linux mint, centos. - -## Role Variables - -From defaults/main.yml : - -```yaml -stern_installation_path: "/opt/github/stern" -stern_checksum: "sha256:e0b39dc26f3a0c7596b2408e4fb8da533352b76aaffdc18c7ad28c833c9eb7db" -stern_version: "1.11.0" -``` - -## Example Playbook - -```yaml -- name: stern installation - hosts: all - become: true - tasks: - - import_role: - name: pandemonium1986.stern -``` - -## Versioning - -We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/Pandemonium1986/ansible-role-stern/tags). - -## Authors - -- **Michael Maffait** - _Initial work_ - [Pandemonium1986](https://github.com/Pandemonium1986) - -See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. - -## License - -This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details diff --git a/ansible/roles/software-k8s-toolbox/stern/defaults/main.yml b/ansible/roles/software-k8s-toolbox/stern/defaults/main.yml deleted file mode 100644 index c0fd9e5..0000000 --- a/ansible/roles/software-k8s-toolbox/stern/defaults/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# https://github.com/wercker/stern -stern_cache_path: "/var/cache/github" -stern_installation_path: "/opt/github/stern" -stern_checksum: "" -stern_version: "v1.22.0" diff --git a/ansible/roles/software-k8s-toolbox/stern/tasks/main.yml b/ansible/roles/software-k8s-toolbox/stern/tasks/main.yml deleted file mode 100644 index 782ad5e..0000000 --- a/ansible/roles/software-k8s-toolbox/stern/tasks/main.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- name: Ensure stern directories are created - file: - path: "{{ stern_installation_path }}" - state: directory - mode: "0755" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Ensure stern is installed - get_url: - url: "{{ source_url }}/{{ github_namespace }}/releases/download/{{ stern_version }}/{{ asset_name }}" - dest: "{{ stern_cache_path }}" - checksum: "{{ stern_checksum }}" - mode: "0755" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Unarchive stern archive into stern_installation_path - unarchive: - src: "{{ stern_cache_path }}/{{ asset_name }}" - dest: "{{ stern_installation_path }}" - remote_src: true - mode: "0755" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Ensure stern link is created - file: - src: "{{ stern_installation_path }}/{{ binary_name }}" - dest: "/usr/local/bin/{{ binary_name }}" - state: link - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software-k8s-toolbox/stern/vars/main.yml b/ansible/roles/software-k8s-toolbox/stern/vars/main.yml deleted file mode 100644 index f5c07ed..0000000 --- a/ansible/roles/software-k8s-toolbox/stern/vars/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -source_url: "https://github.com" -github_namespace: "stern/stern" -asset_name: "stern_1.22.0_linux_amd64.tar.gz" -binary_name: "stern" diff --git a/ansible/roles/software/defaults/main.yml b/ansible/roles/software/defaults/main.yml deleted file mode 100644 index f2e6ba9..0000000 --- a/ansible/roles/software/defaults/main.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -cache_valid_time: 1500 - -rancher_version: "v2.7-head" -rancher_exposed_ports: - - "8100:8080" - -helm_installed_bin_path: "/usr/local/bin/helm" diff --git a/ansible/roles/software/tasks/cleanup.yml b/ansible/roles/software/tasks/cleanup.yml deleted file mode 100644 index 9f18eb6..0000000 --- a/ansible/roles/software/tasks/cleanup.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: Cleanup apt # noqa fqcn-builtins - include_role: - name: system/package_manager/apt - tasks_from: cleanup - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software/tasks/configure_alternative.yml b/ansible/roles/software/tasks/configure_alternative.yml deleted file mode 100644 index d0b8fbc..0000000 --- a/ansible/roles/software/tasks/configure_alternative.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: "Set debian alternatives" - alternatives: - name: "{{ alt.name }}" - path: "{{ alt.path }}" - link: "{{ alt.link }}" - priority: "{{ alt.priority | default(50) }}" - loop: - "{{ software.alternatives.debian | default([]) }}" - loop_control: - loop_var: alt - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software/tasks/install_k8s.yml b/ansible/roles/software/tasks/install_k8s.yml deleted file mode 100644 index 9358d57..0000000 --- a/ansible/roles/software/tasks/install_k8s.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- - -- name: Install minikube - include_role: - name: software-k8s-toolbox/minikube - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install kubectx - include_role: - name: software-k8s-toolbox/kubectx - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install k9s - include_role: - name: software-k8s-toolbox/k9s - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install stern - include_role: - name: software-k8s-toolbox/stern - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install helm - include_role: - name: software-k8s-toolbox/helm - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install rancher - community.docker.docker_container: - name: rancher-server - image: "rancher/rancher:{{ rancher_version }}" - state: started - detach: true - published_ports: "{{ rancher_exposed_ports }}" - pull: true - restart: true - restart_policy: "unless-stopped" diff --git a/ansible/roles/software/tasks/install_latest.yml b/ansible/roles/software/tasks/install_latest.yml deleted file mode 100644 index f81fe32..0000000 --- a/ansible/roles/software/tasks/install_latest.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- - -- name: Install apt # noqa fqcn-builtins - include_role: - name: system/package_manager/apt - tasks_from: install - vars: - keys: "{{ apt.value.repositories_keys | default([]) }}" - repos: "{{ apt.value.repositories | default([]) }}" - packages: "{{ apt.value.packages | default([]) }}" - title: "{{ apt.key | default('') }}" - loop: - "{{ query('dict', software.apt | default({})) }}" - loop_control: - loop_var: apt - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install snap # noqa fqcn-builtins - include_role: - name: system/package_manager/snap - tasks_from: install - vars: - packages: "{{ snap.value.packages | default([]) }}" - title: "{{ snap.key | default('') }}" - loop: - "{{ query('dict', software.snap | default({})) }}" - loop_control: - loop_var: snap - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install pip # noqa fqcn-builtins - include_role: - name: system/package_manager/pip - tasks_from: install - vars: - packages: "{{ pip.value.packages | default([]) }}" - title: "{{ pip.key | default('') }}" - loop: - "{{ query('dict', software.pip | default({})) }}" - loop_control: - loop_var: pip - -- name: Install software with custom commands # noqa fqcn-builtins - register: custom_out - shell: | - {{ custom }} - args: - executable: /bin/bash - loop: - "{{ software.custom | default([]) }}" - loop_control: - loop_var: custom - changed_when: - - "'Changed' in custom_out.stdout" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install k8s - include: install_k8s.yml diff --git a/ansible/roles/software/tasks/main.yml b/ansible/roles/software/tasks/main.yml deleted file mode 100644 index 3bd7610..0000000 --- a/ansible/roles/software/tasks/main.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -- name: Making sure state is defined # noqa fqcn-builtins - assert: - that: - - state is defined - - state in state_valid_options - fail_msg: "'state' parameter is not defined" - quiet: true - -- name: "Action {{ state }}" - include: "{{ state }}.yml" diff --git a/ansible/roles/software/tasks/update_cache.yml b/ansible/roles/software/tasks/update_cache.yml deleted file mode 100644 index faa2fa8..0000000 --- a/ansible/roles/software/tasks/update_cache.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -# Note that this will fail when some repositories are not valid or their keys expired, missing etc. -# It is left to the administrator to ensure that all repositories have been setup correctly. -- name: Ensure that repositories are up to date - ansible.builtin.apt: - update_cache: true - cache_valid_time: "{{ cache_valid_time }}" - # Let's not clutter the output. - changed_when: false diff --git a/ansible/roles/software/tasks/upgrade.yml b/ansible/roles/software/tasks/upgrade.yml deleted file mode 100644 index b83a68d..0000000 --- a/ansible/roles/software/tasks/upgrade.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: Upgrade apt # noqa fqcn-builtins - include_role: - name: system/package_manager/apt - tasks_from: upgrade - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' diff --git a/ansible/roles/software/vars/main.yml b/ansible/roles/software/vars/main.yml deleted file mode 100644 index 6b20cc8..0000000 --- a/ansible/roles/software/vars/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -state_valid_options: - - cleanup - - configure_alternative - - install_latest - - update_cache - - upgrade diff --git a/ansible/roles/system/bluetooth/defaults/main.yml b/ansible/roles/system/bluetooth/defaults/main.yml deleted file mode 100644 index 2512051..0000000 --- a/ansible/roles/system/bluetooth/defaults/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -initramfs_modules: - - bluetooth - -are_we_in_docker: false diff --git a/ansible/roles/system/bluetooth/tasks/enable-on-boot.yml b/ansible/roles/system/bluetooth/tasks/enable-on-boot.yml deleted file mode 100644 index a52ef29..0000000 --- a/ansible/roles/system/bluetooth/tasks/enable-on-boot.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -# https://forums.opensuse.org/showthread.php/525314-How-can-I-insert-a-file-into-the-initramfs -# https://forums.debian.net/viewtopic.php?f=7&t=145644 -# https://www.reddit.com/r/linuxquestions/comments/8774z8/ubuntu_how_can_i_use_my_bluetooth_keyboard_to/ -# https://github.com/dracutdevs/dracut/pull/1139/files -# https://github.com/irreleph4nt/mkinitcpio-bluetooth/blob/master/bluetooth_install -# https://github.com/irreleph4nt/mkinitcpio-bluetooth/blob/master/bluetooth_hook -- name: Add bluetooth modules to initramfs - ansible.builtin.lineinfile: - path: /etc/initramfs-tools/modules - regexp: "^{{ item }}" - line: "{{ item }}" - loop: "{{ initramfs_modules }}" - -- name: Add bluetooth hook and script to initramfs - ansible.builtin.template: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - owner: "root" - group: "root" - mode: "0755" - backup: false - with_items: - - { "src": "initramfs-tools.hooks.bluetooth.j2", "dest": "/etc/initramfs-tools/hooks/bluetooth" } - - { "src": "initramfs-tools.scripts.local-top.bluetooth.j2", "dest": "/etc/initramfs-tools/scripts/local-top/bluetooth" } - - { "src": "initramfs-tools.scripts.local-bottom.bluetooth.j2", "dest": "/etc/initramfs-tools/scripts/local-bottom/bluetooth" } - -- name: update-initramfs # noqa fqcn-builtins - include_role: - name: system/update-initramfs diff --git a/ansible/roles/system/bluetooth/tasks/enable-on-login.yml b/ansible/roles/system/bluetooth/tasks/enable-on-login.yml deleted file mode 100644 index b4711c8..0000000 --- a/ansible/roles/system/bluetooth/tasks/enable-on-login.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- - -- name: Make bluetooth discoverable - ansible.builtin.lineinfile: - insertafter: "^#DiscoverableTimeout *=" - line: "DiscoverableTimeout = 0" - path: /etc/bluetooth/main.conf - regexp: "^DiscoverableTimeout *=.*" - state: "present" - -- name: Make bluetooth discoverable - ansible.builtin.lineinfile: - insertafter: "EOF" - line: "AutoEnable = true" - path: /etc/bluetooth/main.conf - regexp: "^AutoEnable *=.*" - state: "present" - -- name: Make bluetooth fast recoverable - ansible.builtin.lineinfile: - insertafter: "^#FastConnectable *=" - line: "FastConnectable = true" - path: /etc/bluetooth/main.conf - regexp: "^FastConnectable *=.*" - state: "present" - -- name: Set bluetooth connection not to timeout - ansible.builtin.lineinfile: - insertafter: "^#IdleTimeout *=" - line: "IdleTimeout = 0" - path: /etc/bluetooth/input.conf - regexp: "^IdleTimeout *=.*" - state: "present" - -# https://askubuntu.com/questions/1036195/bluetooth-doesnt-work-after-resuming-from-sleep-ubuntu-18-04-lts -- name: Make bluetooth working after sleep - ansible.builtin.template: - src: "lib.systemd.system-sleep.bluetooth.j2" - dest: "/lib/systemd/system-sleep/bt" - owner: "root" - group: "root" - mode: "0755" - backup: false diff --git a/ansible/roles/system/bluetooth/tasks/main.yml b/ansible/roles/system/bluetooth/tasks/main.yml deleted file mode 100644 index 538ee74..0000000 --- a/ansible/roles/system/bluetooth/tasks/main.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- - -- name: Does bluetooh exist? # noqa fqcn-builtins - register: bluetooth_out - shell: | - set -o pipefail - sudo find /var/lib/bluetooth/ -type f -name info -print0 | xargs -0 sudo grep -iE 'Class=0x[0-9a-f]{3}5[4c]0' | wc -l || true - args: - executable: /bin/bash - warn: false - changed_when: false - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- include: enable-on-login.yml - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - - bluetooth_out.stdout | int > 0 - -- include: enable-on-boot.yml - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - - bluetooth_out.stdout | int > 0 - -- include: update-pulseaudio.yml - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - - bluetooth_out.stdout | int > 0 diff --git a/ansible/roles/system/bluetooth/tasks/update-pulseaudio.yml b/ansible/roles/system/bluetooth/tasks/update-pulseaudio.yml deleted file mode 100644 index 158f7ba..0000000 --- a/ansible/roles/system/bluetooth/tasks/update-pulseaudio.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -# JBL bluetooth headphones were not working initially. -# We need to update /etc/pulse/default.pa as per the following article -# https://www.nielsvandermolen.com/bluetooth-headphones-ubuntu/ -# - -- name: Update pulse audio default.pa for module-bluetooth-policy.so - ansible.builtin.replace: - path: /etc/pulse/default.pa - regexp: "^\\.ifexists module-bluetooth-policy\\.so[\\s\\S]*?\\.endif$" - replace: | - #.ifexists module-bluetooth-policy.so - load-module module-bluetooth-policy - #.endif - -- name: Update pulse audio default.pa for module-bluetooth-discover.so - ansible.builtin.replace: - path: /etc/pulse/default.pa - regexp: "^\\.ifexists module-bluetooth-discover\\.so[\\s\\S]*?\\.endif$" - replace: | - #.ifexists module-bluetooth-discover.so - load-module module-bluetooth-discover - #.endif diff --git a/ansible/roles/system/bluetooth/templates/initramfs-tools.hooks.bluetooth.j2 b/ansible/roles/system/bluetooth/templates/initramfs-tools.hooks.bluetooth.j2 deleted file mode 100644 index 32868d4..0000000 --- a/ansible/roles/system/bluetooth/templates/initramfs-tools.hooks.bluetooth.j2 +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh -# -# {{ ansible_managed }} -# Based on https://github.com/irreleph4nt/mkinitcpio-bluetooth/blob/master/bluetooth_install -# - -type=bluetooth -PREREQ="" -prereqs() { - echo "$PREREQ" -} - -case ${1:-""} in -prereqs) - prereqs - exit 0 - ;; -esac - -. /usr/share/initramfs-tools/hook-functions - -add_full_dir() { - # Add a directory and all its contents, recursively, to the initcpio image. - # No parsing is performed and the contents of the directory is added as is. - # $1: type - # $2: path to directory in the local system - - local p= type=$1 path=$2 localPath="$DESTDIR$2" - - if [ -n "$path" ] && [ -d "$path" ]; then - mkdir -p "$localPath" - - for p in "$path"/*; do - if [ -L $p ]; then - ln -sfn "$(readlink "$p")" "$DESTDIR$p" - elif [ -d $p ]; then - add_full_dir "$type" "$p" - elif [ -f $p ]; then - copy_file "$type" "$p" - fi - done - fi - - return 0 -} - -add_file() { - local type=$1 path=$2 localPath="$DESTDIR$2" - - if [ -f "$2" ]; then - mkdir -p "${localPath%/*}" - copy_file "$type" "$path" - fi - - return 0 -} - -force_load bluetooth - -# modules: -for mod in bluetooth btrtl btintel btbcm bnep hidp btusb rfcomm; do - manual_add_modules "$mod" -done - -coreUsers="^root:.*|^systemd-.*|^messagebus:.*|bluetooth:.*" -udevOptions="^tty:.*|^uucp:.*|^kmem:.*|^input:.*|^video:.*|^audio:.*|^lp:.*|^disk:.*|^optical:.*|^storage:.*|^dbus:.*" -for file in group gshadow passwd shadow; do - add_file $type "/etc/$file" - sed -i -E '/'"${coreUsers}"'|'"${udevOptions}"'/!d' "$DESTDIR/etc/$file" -done - -mkdir -p $DESTDIR/etc/dbus-1/session.d/ -mkdir -p $DESTDIR/proc/ -mkdir -p $DESTDIR/run/sdp/ -mkdir -p $DESTDIR/run/dbus/ -mkdir -p $DESTDIR/usr/bin/ -mkdir -p $DESTDIR/usr/lib/ -mkdir -p $DESTDIR/usr/lib/bluetooth/ -mkdir -p $DESTDIR/usr/share/dbus-1/services/ -mkdir -p $DESTDIR/usr/share/dbus-1/session.d/ -mkdir -p $DESTDIR/usr/share/dbus-1/system-services/ -mkdir -p $DESTDIR/var/lib/dbus/ - -add_full_dir $type /lib/lsb/init-functions.d -add_full_dir $type /sys/class/bluetooth -add_full_dir $type /var/lib/bluetooth - -add_file $type /etc/bluetooth/main.conf -add_file $type /etc/dbus-1/system.d/bluetooth.conf -add_file $type /etc/default/dbus -add_file $type /etc/init.d/dbus -add_file $type /etc/machine-id -add_file $type /lib/lsb/init-functions -add_file $type /usr/lib/modprobe.d/bluetooth-usb.conf -add_file $type /usr/lib/modules-load.d/bluez.conf -add_file $type /usr/lib/sysusers.d/dbus.conf -add_file $type /usr/lib/tmpfiles.d/dbus.conf -add_file $type /usr/share/dbus-1/session.conf -add_file $type /usr/share/dbus-1/system.conf -add_file $type /usr/share/dbus-1/system-services/org.bluez.service - -copy_exec /usr/bin/bluetoothctl -copy_exec /usr/bin/dbus-daemon -copy_exec /usr/bin/dbus-launch -copy_exec /usr/bin/dbus-uuidgen -copy_exec /usr/bin/id -copy_exec /usr/bin/mountpoint -copy_exec /bin/xargs -copy_exec /usr/lib/bluetooth/bluetoothd -copy_exec /usr/sbin/nologin -copy_exec /usr/sbin/groupadd -copy_exec /usr/sbin/start-stop-daemon -copy_exec /usr/sbin/useradd - -ln -sfn "/etc/machine-id" "$DESTDIR/var/lib/dbus/machine-id" -ln -sfn "/run" "$DESTDIR/var/run" - -exit 0 diff --git a/ansible/roles/system/bluetooth/templates/initramfs-tools.scripts.local-bottom.bluetooth.j2 b/ansible/roles/system/bluetooth/templates/initramfs-tools.scripts.local-bottom.bluetooth.j2 deleted file mode 100644 index f2dfa1d..0000000 --- a/ansible/roles/system/bluetooth/templates/initramfs-tools.scripts.local-bottom.bluetooth.j2 +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# -# {{ ansible_managed }} - -PREREQ="lvm,udev" -prereqs() { - echo "$PREREQ" -} - -case ${1:-""} in -prereqs) - prereqs - exit 0 - ;; -esac - -quiet=${quiet:-"no"} -. /scripts/functions -log_success_msg "Inside initramfs-tools/scripts/local-bottom/bluetooth" - -log_begin_msg "Killing all bluetoothd..." -ps | grep /usr/lib/bluetooth/bluetoothd | grep -v grep | awk -F ' ' '{ print $1 }' | xargs --no-run-if-empty kill -9 -log_end_msg - -exit 0 diff --git a/ansible/roles/system/bluetooth/templates/initramfs-tools.scripts.local-top.bluetooth.j2 b/ansible/roles/system/bluetooth/templates/initramfs-tools.scripts.local-top.bluetooth.j2 deleted file mode 100644 index b1b5f26..0000000 --- a/ansible/roles/system/bluetooth/templates/initramfs-tools.scripts.local-top.bluetooth.j2 +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# -# {{ ansible_managed }} -# Based on https://github.com/irreleph4nt/mkinitcpio-bluetooth/blob/master/bluetooth_hook -# - -PREREQ="lvm,udev" -prereqs() { - echo "$PREREQ" -} - -case ${1:-""} in -prereqs) - prereqs - exit 0 - ;; -esac - -quiet=${quiet:-"no"} -. /scripts/functions -log_success_msg "Inside initramfs-tools/scripts/local-top/bluetooth" - -if [ ! -x "/usr/lib/bluetooth/bluetoothd" ] && [ ! -x "/usr/bin/dbus-daemon" ]; then - panic "bluetoothd or dbus-daemon executable are not found" -fi -log_success_msg "bluetoothd and dbus-daemon exist." - -groupadd --gid 106 messagebus -useradd --gid messagebus --uid 103 --home-dir /nonexistent --shell /usr/sbin/nologin messagebus || true - -log_begin_msg "Activating dbus..." -mkdir -p /run/dbus/ -/etc/init.d/dbus status -/etc/init.d/dbus start -# This can be used instead of the init.d script. -#/usr/bin/dbus-daemon --system --syslog --print-address -log_end_msg -log_success_msg "dbus-daemon started" -/etc/init.d/dbus status - -log_begin_msg "Activating bluetoothd..." -ps | grep /usr/lib/bluetooth/bluetoothd | grep -v grep | awk -F ' ' '{ print $1 }' | xargs --no-run-if-empty kill -9 -/usr/lib/bluetooth/bluetoothd & -log_end_msg - -exit 0 diff --git a/ansible/roles/system/bluetooth/templates/lib.systemd.system-sleep.bluetooth.j2 b/ansible/roles/system/bluetooth/templates/lib.systemd.system-sleep.bluetooth.j2 deleted file mode 100644 index c5d0949..0000000 --- a/ansible/roles/system/bluetooth/templates/lib.systemd.system-sleep.bluetooth.j2 +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# {{ ansible_managed }} -# - -case $1 in - post) - sudo modprobe -r btusb - sleep 1 - sudo systemctl restart bluetooth - sleep 1 - sudo modprobe btusb - ;; -esac diff --git a/ansible/roles/system/locale/defaults/main.yml b/ansible/roles/system/locale/defaults/main.yml deleted file mode 100644 index 50f4e80..0000000 --- a/ansible/roles/system/locale/defaults/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -system: - locale: "en_GB.UTF-8" - language: "en_GB.UTF-8" - timezone: "Asia/Singapore" - -are_we_in_docker: false diff --git a/ansible/roles/system/locale/tasks/locale-debian.yml b/ansible/roles/system/locale/tasks/locale-debian.yml deleted file mode 100644 index acb28fb..0000000 --- a/ansible/roles/system/locale/tasks/locale-debian.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -# ----------------------------------------------------------------------------- -# This is based on https://serverfault.com/questions/959026/how-do-i-generate-and-set-the-locale-using-ansible. -# ----------------------------------------------------------------------------- - -- name: Ensure localisation files for '{{ system.locale }}' are available - ansible.builtin.locale_gen: - name: "{{ system.locale }}" - state: present - -- name: Ensure localisation files for '{{ system.language }}' are available - ansible.builtin.locale_gen: - name: "{{ system.language }}" - state: present - -- name: Get current locale and language configuration # noqa fqcn-builtins - register: locale_status - shell: >- - localectl status - changed_when: false - -- name: Parse 'LANG' from current locale and language configuration - ansible.builtin.set_fact: - locale_lang: "{{ locale_status.stdout | regex_search('LANG=([^\n]+)', '\\1') | first }}" - -- name: Parse 'LANGUAGE' from current locale and language configuration - ansible.builtin.set_fact: - locale_language: "{{ locale_status.stdout | regex_search('LANGUAGE=([^\n]+)', '\\1') | default([locale_lang], true) | first }}" - -- name: Current locale data - ansible.builtin.debug: - msg: "Will update LANG from {{ locale_lang }} to {{ system.locale }}, and LANGUAGE from {{ locale_language }} to {{ system.language }}." - when: - - locale_lang != system.locale or locale_language != system.language - -- name: Configure locale to '{{ system.locale }}' and language to '{{ system.language }}' # noqa fqcn-builtins - shell: >- - localectl set-locale LANG={{ system.locale }} LANGUAGE={{ system.language }} - when: - - locale_lang != system.locale or locale_language != system.language diff --git a/ansible/roles/system/locale/tasks/main.yml b/ansible/roles/system/locale/tasks/main.yml deleted file mode 100644 index 186809a..0000000 --- a/ansible/roles/system/locale/tasks/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: Locale for Debian - include: locale-debian.yml - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - # localectl commands do not work inside docker... - - not are_we_in_docker diff --git a/ansible/roles/system/package_manager/apt/defaults/main.yml b/ansible/roles/system/package_manager/apt/defaults/main.yml deleted file mode 100644 index 3ab6006..0000000 --- a/ansible/roles/system/package_manager/apt/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- - -cache_valid_time: 3600 diff --git a/ansible/roles/system/package_manager/apt/tasks/add_key.yml b/ansible/roles/system/package_manager/apt/tasks/add_key.yml deleted file mode 100644 index 20e39fb..0000000 --- a/ansible/roles/system/package_manager/apt/tasks/add_key.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- name: "Install key for {{ title | default('') }}" - ansible.builtin.apt_key: - url: "{{ url }}" - state: "{{ state }}" diff --git a/ansible/roles/system/package_manager/apt/tasks/add_repository.yml b/ansible/roles/system/package_manager/apt/tasks/add_repository.yml deleted file mode 100644 index 3c381c0..0000000 --- a/ansible/roles/system/package_manager/apt/tasks/add_repository.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: "Add repository for {{ title | default('') }}" - ansible.builtin.apt_repository: - repo: "{{ repo }}" - state: "{{ state }}" - update_cache: true - validate_certs: false diff --git a/ansible/roles/system/package_manager/apt/tasks/cleanup.yml b/ansible/roles/system/package_manager/apt/tasks/cleanup.yml deleted file mode 100644 index 5c6e320..0000000 --- a/ansible/roles/system/package_manager/apt/tasks/cleanup.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -- name: Cleanup not needed software - register: software_cleanup_output - ansible.builtin.apt: - autoclean: true - -- name: Cleanup logs - ansible.builtin.debug: - msg: "{{ software_cleanup_output }}" - changed_when: false diff --git a/ansible/roles/system/package_manager/apt/tasks/configure.yml b/ansible/roles/system/package_manager/apt/tasks/configure.yml deleted file mode 100644 index fe89e9e..0000000 --- a/ansible/roles/system/package_manager/apt/tasks/configure.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: Ensure the system can use the HTTPS transport for APT - register: apt_https_transport - ansible.builtin.stat: - path: "/usr/lib/apt/methods/https" - -- name: Install HTTPS transport for APT - ansible.builtin.apt: - pkg: apt-transport-https - state: installed - when: - - not apt_https_transport.stat.exists - -- name: Enable all repositories in sources.list - ansible.builtin.replace: - path: /etc/apt/sources.list - regexp: '^#\s?deb(.+)http://(.+)/ubuntu(.+)$' - replace: 'deb\1http://\2/ubuntu\3' - backup: false diff --git a/ansible/roles/system/package_manager/apt/tasks/install.yml b/ansible/roles/system/package_manager/apt/tasks/install.yml deleted file mode 100644 index 9316bed..0000000 --- a/ansible/roles/system/package_manager/apt/tasks/install.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -- name: Adding repository key - include: add_key.yml - vars: - url: "{{ key }}" - state: "present" - loop: - "{{ keys | default([]) | list }}" - loop_control: - loop_var: key - -- name: Adding repository - include: add_repository.yml - vars: - repo: "{{ repository }}" - state: "present" - loop: - "{{ repos | default([]) | list }}" - loop_control: - loop_var: repository - -- name: "Install latest version of software for {{ title }}" - ansible.builtin.apt: - pkg: "{{ packages | list }}" - state: "latest" # noqa package-latest - update_cache: true - cache_valid_time: "{{ cache_valid_time }}" - force_apt_get: true - when: - - packages is defined - - packages | length > 0 diff --git a/ansible/roles/system/package_manager/apt/tasks/upgrade.yml b/ansible/roles/system/package_manager/apt/tasks/upgrade.yml deleted file mode 100644 index b3f8aa4..0000000 --- a/ansible/roles/system/package_manager/apt/tasks/upgrade.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- - -- name: Update apt repo and cache on all Debian/Ubuntu boxes - ansible.builtin.apt: - update_cache: true - force_apt_get: true - cache_valid_time: "{{ cache_valid_time }}" - -- name: Upgrade all packages on servers - register: software_upgrade_output - ansible.builtin.apt: - autoremove: true - force_apt_get: true - install_recommends: false - upgrade: "dist" - -- name: Upgrade logs - ansible.builtin.debug: - msg: "{{ software_upgrade_output }}" - changed_when: false - -- name: Check if a reboot is needed on all servers - register: reboot_required_file - ansible.builtin.stat: - path: /var/run/reboot-required - get_md5: false - changed_when: false - -- name: Notify user that a reboot is needed - ansible.builtin.shell: >- - sudo -iu "{{ system_user.key }}" sh -c "notify-send -t 0 -i face-wink 'Reboot is needed' 'Automated unattended upgrade has finished. A system reboot is required.'" - loop: - "{{ query('dict', users | default({})) }}" - loop_control: - loop_var: system_user - failed_when: false - when: - - reboot_required_file.stat.exists diff --git a/ansible/roles/system/package_manager/pip/tasks/install.yml b/ansible/roles/system/package_manager/pip/tasks/install.yml deleted file mode 100644 index b285321..0000000 --- a/ansible/roles/system/package_manager/pip/tasks/install.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "Install pip packages of software for {{ title }}" - ansible.builtin.pip: - name: "{{ packages | list }}" - state: "latest" # noqa package-latest - extra_args: "--ignore-installed" - when: - - packages is defined - - packages | length > 0 diff --git a/ansible/roles/system/package_manager/snap/defaults/main.yml b/ansible/roles/system/package_manager/snap/defaults/main.yml deleted file mode 100644 index adab5a3..0000000 --- a/ansible/roles/system/package_manager/snap/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- - -are_we_in_docker: false diff --git a/ansible/roles/system/package_manager/snap/tasks/install.yml b/ansible/roles/system/package_manager/snap/tasks/install.yml deleted file mode 100644 index 33dda11..0000000 --- a/ansible/roles/system/package_manager/snap/tasks/install.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- - -- name: "Install latest version of software for {{ title }}" - snap: - name: "{{ package }}" - state: "present" - classic: "yes" - loop: - "{{ packages | default([]) | list }}" - loop_control: - loop_var: package - when: - # snapd does not work inside docker. We can bind our container with - # snapd of the host system, but let's not do that now... - - not are_we_in_docker diff --git a/ansible/roles/system/timezone/defaults/main.yml b/ansible/roles/system/timezone/defaults/main.yml deleted file mode 100644 index 8bf9efb..0000000 --- a/ansible/roles/system/timezone/defaults/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -system: - timezone: "Asia/Singapore" - -are_we_in_docker: false diff --git a/ansible/roles/system/timezone/tasks/main.yml b/ansible/roles/system/timezone/tasks/main.yml deleted file mode 100644 index aff3203..0000000 --- a/ansible/roles/system/timezone/tasks/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Set timezone - register: test_out - timezone: - name: "{{ system.timezone }}" - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - # timedatectl command does not work inside docker... - - not are_we_in_docker diff --git a/ansible/roles/system/update-initramfs/tasks/main.yml b/ansible/roles/system/update-initramfs/tasks/main.yml deleted file mode 100644 index 31de7ce..0000000 --- a/ansible/roles/system/update-initramfs/tasks/main.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- - -- name: Update initramfs # noqa fqcn-builtins - register: update_initramfs_out - become: true - become_user: "root" - shell: >- - update-initramfs -u -k $(uname -r) - when: - - ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: update-initramfs logs - ansible.builtin.debug: - msg: "{{ update_initramfs_out }}" - changed_when: false diff --git a/ansible/roles/system/user/defaults/main.yml b/ansible/roles/system/user/defaults/main.yml deleted file mode 100644 index 02aad2d..0000000 --- a/ansible/roles/system/user/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -are_we_in_docker: false - -users: {} diff --git a/ansible/roles/system/user/tasks/main.yml b/ansible/roles/system/user/tasks/main.yml deleted file mode 100644 index 0fd0d11..0000000 --- a/ansible/roles/system/user/tasks/main.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -# users: -# dkafetzi: -# name: "Dimitris Kafetzis" -# email: "kafetzis.dimitris.andreas@gmail.com" -# admin: -# name: "Admin" -- name: Create users - ansible.builtin.user: - name: "{{ user.key }}" - shell: "/bin/bash" - state: "present" - loop: "{{ query('dict', users | default({})) }}" - loop_control: - loop_var: user diff --git a/ansible/roles/utils/are_we_in_docker/tasks/main.yml b/ansible/roles/utils/are_we_in_docker/tasks/main.yml deleted file mode 100644 index d53e796..0000000 --- a/ansible/roles/utils/are_we_in_docker/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -# https://tuhrig.de/how-to-know-you-are-inside-a-docker-container/ -- name: Checking whether we are inside docker # noqa fqcn-builtins - register: inside_docker_out - shell: | - set -o pipefail - cat /proc/self/cgroup | grep -c "/docker/" || true - args: - executable: /bin/bash - changed_when: false - -- name: Set are_we_in_docker fact - ansible.builtin.set_fact: - are_we_in_docker: "{{ inside_docker_out.stdout | int != 0 }}" - -- name: Log are_we_in_docker fact - ansible.builtin.debug: - var: are_we_in_docker diff --git a/ansible/settings-system.yml b/ansible/settings-system.yml deleted file mode 100644 index 120e46a..0000000 --- a/ansible/settings-system.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -- name: Apply system wide settings - hosts: all - roles: - - - role: utils/are_we_in_docker - - - role: system/locale - - - role: system/timezone diff --git a/ansible/settings-user.yml b/ansible/settings-user.yml deleted file mode 100644 index 2bac6d2..0000000 --- a/ansible/settings-user.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- - -- name: Apply user specific settings - hosts: all - roles: - - - role: utils/are_we_in_docker - - - role: settings/user - when: - - settings_user is defined - - - role: settings/application - when: - - settings_application is defined diff --git a/ansible/software-install.yml b/ansible/software-install.yml deleted file mode 100644 index 3cd10dd..0000000 --- a/ansible/software-install.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -- name: Setup software - hosts: all - roles: - - - role: utils/are_we_in_docker - - - role: software - vars: - state: install_latest - cache_valid_time: "{{ package_manager.cache_valid_time }}" - when: - - software is defined - - - role: software - vars: - state: install_latest - cache_valid_time: "{{ package_manager.cache_valid_time }}" - when: - - software is defined - - - role: software - vars: - state: configure_alternative - when: - - software is defined - - - role: software - vars: - state: cleanup diff --git a/ansible/software-update.yml b/ansible/software-update.yml deleted file mode 100644 index b84d8fa..0000000 --- a/ansible/software-update.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- - -- name: Unattended software upgrade - hosts: all - roles: - - - role: utils/are_we_in_docker - - - role: software - vars: - state: upgrade - cache_valid_time: "{{ package_manager.cache_valid_time }}" - when: - - software is defined - - - role: software - vars: - state: cleanup diff --git a/ansible/system-bluetooth.yml b/ansible/system-bluetooth.yml deleted file mode 100644 index 4d334ae..0000000 --- a/ansible/system-bluetooth.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- name: Setup bluetooth - hosts: all - roles: - - - role: utils/are_we_in_docker - - - role: system/bluetooth diff --git a/ansible/system-user.yml b/ansible/system-user.yml deleted file mode 100644 index 3a13951..0000000 --- a/ansible/system-user.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -# Note that we expect the users to already exist in the system, -# as this role is very basic. - -- name: Create users - hosts: all - roles: - - - role: utils/are_we_in_docker - - - role: system/user - when: - - users is defined diff --git a/ansible/tools-gather_facts.yml b/ansible/tools-gather_facts.yml deleted file mode 100644 index 2019fd9..0000000 --- a/ansible/tools-gather_facts.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- name: Gather facts and source external variables - hosts: all - tasks: - gather_facts: true diff --git a/docker-entrypoint-one-time.sh b/docker-entrypoint-one-time.sh deleted file mode 100755 index 02c8569..0000000 --- a/docker-entrypoint-one-time.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -ueo pipefail - -./scripts/one-time-debian.sh diff --git a/docker-entrypoint-scheduled.sh b/docker-entrypoint-scheduled.sh deleted file mode 100755 index 3336ad4..0000000 --- a/docker-entrypoint-scheduled.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -ueo pipefail - -sudo -u admin sh -c "./scripts/scheduled-debian.sh" diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100755 index 6c36682..0000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -set -ueo pipefail - -./docker-entrypoint-one-time.sh -./docker-entrypoint-scheduled.sh diff --git a/docker/Dockerfile.ubuntu-20.04 b/docker/Dockerfile.ubuntu-20.04 new file mode 100644 index 0000000..96dd0e2 --- /dev/null +++ b/docker/Dockerfile.ubuntu-20.04 @@ -0,0 +1,115 @@ +# ----------------------------------------------------------------------------- +# We need to have a base so that we do not install ansible, sudo etc by default. +# We want the script to handle them. +FROM ubuntu:20.04 as base + +ENV \ + LANG=C.UTF-8 \ + DEBIAN_FRONTEND=noninteractive \ + # Do not buffer log output \ + PYTHONUNBUFFERED=1 + +ENV \ + DOCKER_DIR="/opt/docker" \ + BASE_DIR="/opt/automated-workstation" \ + RUNTIME_DIR="/opt/automated-workstation/app" \ + USER_AUTOMATION="automation" + +WORKDIR $RUNTIME_DIR + +# Let's install some helpful tools. +RUN apt-get update -qq \ + && apt-get install --yes --no-install-recommends \ + apt-transport-https \ + apt-utils \ + ca-certificates \ + cron \ + curl \ + dbus-x11 \ + dirmngr \ + less \ + libnotify-bin \ + locales \ + iputils-ping \ + net-tools \ + netcat \ + notify-osd \ + sudo \ + software-properties-common \ + vim \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# ----------------------------------------------------------------------------- +FROM base as runtime + +# Let's create a random user as it would be the case in real world. +RUN \ + groupadd -g 999 $USER_AUTOMATION \ + && useradd -m -u 999 -s /bin/bash -g $USER_AUTOMATION -G sudo $USER_AUTOMATION \ + && echo "$USER_AUTOMATION ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \ + && touch /home/$USER_AUTOMATION/.sudo_as_admin_successful + +RUN chown -R $USER_AUTOMATION:$USER_AUTOMATION $BASE_DIR + +USER $USER_AUTOMATION + +LABEL stage RUNTIME + +# ----------------------------------------------------------------------------- +FROM base as test + +ENV \ + BUILD_DIR="/home/builder/build" \ + VENV="/home/builder/.venv" \ + # Keeps Python from generating .pyc files in the container. \ + PYTHONDONTWRITEBYTECODE=1 \ + USER_BUILDER="builder" + +RUN apt-get update -qq \ + && apt-get install --yes --no-install-recommends \ + python3.9 \ + python3.9-venv \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN \ + groupadd -g 999 $USER_BUILDER \ + && useradd -r -m -u 999 -g $USER_BUILDER $USER_BUILDER + +USER $USER_BUILDER +WORKDIR $BUILD_DIR + +RUN python3.9 -m venv $VENV +ENV PATH="$VENV/bin:$PATH" + +RUN . $VENV/bin/activate \ + && pip3.9 install --upgrade \ + ansible-lint \ + yamllint + +COPY ./ansible ./ansible/ +COPY ./.ansible-lint .ansible-lint +COPY ./.yamllint.yml .yamllint.yml + +RUN . $VENV/bin/activate \ + && ansible-lint + +LABEL stage TEST + +# ----------------------------------------------------------------------------- +FROM runtime as production + +COPY ./docker/*.sh $DOCKER_DIR/ +COPY ./scripts ./scripts/ +COPY ./ansible ./ansible/ + +USER root +RUN chown -R $USER_AUTOMATION:$USER_AUTOMATION $DOCKER_DIR \ + && chown -R $USER_AUTOMATION:$USER_AUTOMATION $RUNTIME_DIR \ + && chmod 755 $DOCKER_DIR/*.sh +USER $USER_AUTOMATION + +ENTRYPOINT $DOCKER_DIR/docker-entrypoint.sh + +LABEL stage PRODUCTION diff --git a/docker/Dockerfile.ubuntu-22.04 b/docker/Dockerfile.ubuntu-22.04 new file mode 100644 index 0000000..a81852c --- /dev/null +++ b/docker/Dockerfile.ubuntu-22.04 @@ -0,0 +1,115 @@ +# ----------------------------------------------------------------------------- +# We need to have a base so that we do not install ansible, sudo etc by default. +# We want the script to handle them. +FROM ubuntu:22.04 as base + +ENV \ + LANG=C.UTF-8 \ + DEBIAN_FRONTEND=noninteractive \ + # Do not buffer log output \ + PYTHONUNBUFFERED=1 + +ENV \ + DOCKER_DIR="/opt/docker" \ + BASE_DIR="/opt/automated-workstation" \ + RUNTIME_DIR="/opt/automated-workstation/app" \ + USER_AUTOMATION="automation" + +WORKDIR $RUNTIME_DIR + +# Let's install some helpful tools. +RUN apt-get update -qq \ + && apt-get install --yes --no-install-recommends \ + apt-transport-https \ + apt-utils \ + ca-certificates \ + cron \ + curl \ + dbus-x11 \ + dirmngr \ + less \ + libnotify-bin \ + locales \ + iputils-ping \ + net-tools \ + netcat \ + notify-osd \ + software-properties-common \ + sudo \ + vim \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# ----------------------------------------------------------------------------- +FROM base as runtime + +# Let's create a random user as it would be the case in real world. +RUN \ + groupadd -g 999 $USER_AUTOMATION \ + && useradd -m -u 999 -s /bin/bash -g $USER_AUTOMATION -G sudo $USER_AUTOMATION \ + && echo "$USER_AUTOMATION ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \ + && touch /home/$USER_AUTOMATION/.sudo_as_admin_successful + +RUN chown -R $USER_AUTOMATION:$USER_AUTOMATION $BASE_DIR + +USER $USER_AUTOMATION + +LABEL stage RUNTIME + +# ----------------------------------------------------------------------------- +FROM base as test + +ENV \ + BUILD_DIR="/home/builder/build" \ + VENV="/home/builder/.venv" \ + # Keeps Python from generating .pyc files in the container. \ + PYTHONDONTWRITEBYTECODE=1 \ + USER_BUILDER="builder" + +RUN apt-get update -qq \ + && apt-get install --yes --no-install-recommends \ + python3 \ + python3-venv \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN \ + groupadd -g 999 $USER_BUILDER \ + && useradd -r -m -u 999 -g $USER_BUILDER $USER_BUILDER + +USER $USER_BUILDER +WORKDIR $BUILD_DIR + +RUN python3 -m venv $VENV +ENV PATH="$VENV/bin:$PATH" + +RUN . $VENV/bin/activate \ + && pip install --upgrade \ + ansible-lint \ + yamllint + +COPY ./ansible ./ansible/ +COPY ./.ansible-lint .ansible-lint +COPY ./.yamllint.yml .yamllint.yml + +RUN . $VENV/bin/activate \ + && ansible-lint + +LABEL stage TEST + +# ----------------------------------------------------------------------------- +FROM runtime as production + +COPY ./docker/*.sh $DOCKER_DIR/ +COPY ./scripts ./scripts/ +COPY ./ansible ./ansible/ + +USER root +RUN chown -R $USER_AUTOMATION:$USER_AUTOMATION $DOCKER_DIR \ + && chown -R $USER_AUTOMATION:$USER_AUTOMATION $RUNTIME_DIR \ + && chmod 755 $DOCKER_DIR/*.sh +USER $USER_AUTOMATION + +ENTRYPOINT $DOCKER_DIR/docker-entrypoint.sh + +LABEL stage PRODUCTION diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100755 index 0000000..a82d0f3 --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -ueo pipefail + +export DEBIAN_FRONTEND=noninteractive + +export ADMIN_USERNAME=${ADMIN_USERNAME:-admin} + +$RUNTIME_DIR/scripts/one-time-debian.sh +if [ "$?" -gt 0 ]; then + echo "one-time-debian.sh failed" +fi + +sudo -u $ADMIN_USERNAME sh -c "$RUNTIME_DIR/scripts/scheduled-debian.sh" diff --git a/scripts/add-cronjob-debian.sh b/scripts/add-cronjob-debian.sh index feceb14..a1c77a7 100755 --- a/scripts/add-cronjob-debian.sh +++ b/scripts/add-cronjob-debian.sh @@ -4,9 +4,12 @@ # set -ueo pipefail -log() { - echo "`date +"%Y-%m-%d %H:%M:%S"`: $1" -} +export ADMIN_USERNAME=${ADMIN_USERNAME:-admin} + +export APP_DIR=${APP_DIR:-/opt/automated-workstation/app} +export VENV_DIR=${VENV_DIR:-/opt/automated-workstation/.venv} + +. $APP_DIR/scripts/setup-env.sh log "" log "---------------------------" @@ -15,18 +18,16 @@ log "" oldPwd=`pwd` -cd ansible/ -# Just delete any caching directory. -fact_caching_connection=`grep -E "^fact_caching_connection *=" ./ansible.cfg | sed 's/fact_caching_connection=//g'` -if [ -d $fact_caching_connection ]; then - log "Removing $fact_caching_connection directory." - sudo rm -rf $fact_caching_connection -fi - # Run ansible -cmd=(ansible-playbook -b -u admin 00-add-cronjob.yml) -log "In directory: `pwd`." -log "Executing: ${cmd[*]}" -"${cmd[@]}" +run_ansible() { + . $VENV_DIR/bin/activate + cd $APP_DIR/ansible + + log "In directory: `pwd`." + log "Executing: ansible-playbook -b -u $ADMIN_USERNAME amolofos.ansible_collection_workstation.p00_add_cronjob" + ansible-playbook -b -u $ADMIN_USERNAME amolofos.ansible_collection_workstation.p00_add_cronjob + + cd $oldPwd +} -cd $oldPwd +run_ansible diff --git a/scripts/one-time-debian.sh b/scripts/one-time-debian.sh index 75e51fb..f3f13cd 100755 --- a/scripts/one-time-debian.sh +++ b/scripts/one-time-debian.sh @@ -2,14 +2,23 @@ # # It is expected to be run by root or any other privileged user. # +# This script should not depend on any other ones. The user must be +# able to run it without the need to checkout the entiry codebase first. +# set -ueo pipefail -ADMIN_USERNAME=admin -ADMIN_GROUP=admin +export ADMIN_USERNAME=${ADMIN_USERNAME:-admin} +export ADMIN_GROUP=${ADMIN_GROUP:-admin} + +export BASE_DIR=${BASE_DIR:-/opt/automated-workstation} +export APP_DIR=${APP_DIR:-/opt/automated-workstation/app} -DEBIAN_FRONTEND=noninteractive -REPOSITORY_BRANCH=${GIT_BRANCH:-main} -REPOSITORY=${REPOSITORY:-https://github.com/amolofos/automated-workstation-setup.git} +export REPOSITORY_BRANCH=${GIT_BRANCH:-main} +export REPOSITORY=${REPOSITORY:-https://github.com/amolofos/automated-workstation-setup.git} + +export PYTHON_VERSION=${PYTHON_VERSION:-python3} +export PYTHON_PIP_VERSION=${PYTHON_PIP_VERSION:-pip3} +export ANSIBLE_COLLECTIONS_PATH="~/.ansible/collections" log() { echo "`date +"%Y-%m-%d %H:%M:%S"`: $1" @@ -30,7 +39,7 @@ echo "" if [ "$(id -u)" -eq "0" ]; then log "Installing sudo" - apt-get update -qq >/dev/null 2>&1 && apt-get install --yes sudo >/dev/null 2>&1 || true + apt-get update -qq && apt-get install --yes sudo || true fi if ! command -v sudo >/dev/null 2>&1; then @@ -43,7 +52,7 @@ log "Create $ADMIN_GROUP group." sudo groupadd --system --force $ADMIN_GROUP log "Set $ADMIN_GROUP group as passwordless sudo." -echo "# `date +"%Y-%m-%d %H:%M:%S"`" > /tmp/99-admin-passwordless.new +echo "# `date +"%Y-%m-%d %H:%M:%S"`" > /tmp/99-admin-passwordless.new echo "# Give $ADMIN_GROUP group passwordless sudo." >> /tmp/99-admin-passwordless.new echo "%$ADMIN_GROUP ALL=(ALL) NOPASSWD:ALL" >> /tmp/99-admin-passwordless.new visudo --check --quiet --strict -f /tmp/99-admin-passwordless.new @@ -51,21 +60,27 @@ sudo EDITOR="cp /tmp/99-admin-passwordless.new" visudo -f /etc/sudoers.d/99-admi rm -f /tmp/99-admin-passwordless.new log "Create $ADMIN_USERNAME system user." -id -u $ADMIN_USERNAME >/dev/null 2>&1 || sudo useradd --system --create-home --gid $ADMIN_GROUP $ADMIN_USERNAME +id -u $ADMIN_USERNAME >/dev/null 2>&1 || sudo useradd --create-home -s /bin/bash --gid $ADMIN_GROUP $ADMIN_USERNAME sudo usermod -a -G '' admin +sudo touch /home/$ADMIN_USERNAME/.sudo_as_admin_successful -log "Installing software-properties-common" -sudo apt-get update -qq >/dev/null 2>&1 && \ - sudo apt-get install -qq --yes --no-install-recommends software-properties-common +log "Installing software-properties-common and gpg" +sudo apt-get update -qq +sudo apt-get install -qq --yes --no-install-recommends \ + software-properties-common \ + gpg \ + gpg-agent \ + rng-tools -log "Installing python 3.8 and ansible" +log "Installing python and git" sudo add-apt-repository --yes ppa:deadsnakes/ppa sudo apt-add-repository --yes ppa:ansible/ansible -sudo apt-get update -qq >/dev/null 2>&1 && \ - sudo apt-get install -qq --yes --no-install-recommends ansible git python3.8 python3-apt - -log "Installing GPG" -sudo apt-get install -qq --yes --no-install-recommends gpg gpg-agent rng-tools +sudo apt-get update -qq +sudo apt-get install -qq --yes --no-install-recommends \ + git \ + python3-apt \ + ${PYTHON_VERSION} \ + ${PYTHON_VERSION}-venv log "Installing a crontab to $ADMIN_USERNAME user." log "This will:" @@ -78,30 +93,40 @@ log " the scheduled-debian.sh script." log "" oldPwd=`pwd` +oldUser=`whoami` -if [ -f "./scripts/add-cronjob-debian.sh" ]; then - cmd=(sudo -iu admin sh -c "cd $oldPwd; ./scripts/add-cronjob-debian.sh") +sudo chown -R $ADMIN_USERNAME:$ADMIN_GROUP $BASE_DIR; - # Just delete any caching directory. - fact_caching_connection=`grep -E "^fact_caching_connection *=" ./ansible/ansible.cfg | sed 's/fact_caching_connection=//g'` - if [ -d $fact_caching_connection ]; then - log "Removing $fact_caching_connection directory." - sudo rm -rf $fact_caching_connection - fi - sudo chown admin:admin ansible/ +if [ -f "$APP_DIR/scripts/add-cronjob-debian.sh" ]; then + cmd() { + log "In directory: `pwd`." + log "Executing: sudo -u $ADMIN_USERNAME sh -c '$APP_DIR/scripts/add-cronjob-debian.sh'" + + sudo -u $ADMIN_USERNAME sh -c " + $APP_DIR/scripts/add-cronjob-debian.sh; + " + } + + cmd else - cmd=(sudo -iu admin sh -c "rm -rf /tmp/amolofos-automated-workstation-setup-tmp/ && \ - git clone --quiet --branch $REPOSITORY_BRANCH $REPOSITORY --depth 1 /tmp/amolofos-automated-workstation-setup-tmp/ && \ - cd /tmp/amolofos-automated-workstation-setup-tmp/ && \ - ./scripts/add-cronjob-debian.sh && \ - cd /tmp \ - && rm -rf /tmp/amolofos-automated-workstation-setup-tmp/ \ - ") + sudo mkdir -p $APP_DIR + sudo chown -R $ADMIN_USERNAME:$ADMIN_GROUP $BASE_DIR + + cmd() { + sudo -iu admin sh -c " + rm -rf $APP_DIR && + git clone --quiet --branch $REPOSITORY_BRANCH $REPOSITORY --depth 1 $APP_DIR && + cd $APP_DIR && + $APP_DIR/scripts/add-cronjob-debian.sh && + cd $HOME && + rm -rf $APP_DIR + " + } + + log "In directory: `pwd`." + log "Executing: $APP_DIR/scripts/add-cronjob-debian.sh" + cmd fi -log "In directory: `pwd`." -log "Executing: ${cmd[*]}" -"${cmd[@]}" - log "Finished successfully." diff --git a/scripts/scheduled-debian.sh b/scripts/scheduled-debian.sh index f3a67bf..1acab90 100755 --- a/scripts/scheduled-debian.sh +++ b/scripts/scheduled-debian.sh @@ -4,9 +4,12 @@ # set -ueo pipefail -log() { - echo "`date +"%Y-%m-%d %H:%M:%S"`: $1" -} +export ADMIN_USERNAME=${ADMIN_USERNAME:-admin} + +export APP_DIR=${APP_DIR:-/opt/automated-workstation/app} +export VENV_DIR=${VENV_DIR:-/opt/automated-workstation/.venv} + +. $APP_DIR/scripts/setup-env.sh log "" log "---------------------------" @@ -15,29 +18,18 @@ log "" oldPwd=`pwd` -cd ansible/ -# Just delete any caching directory. -fact_caching_connection=`grep -E "^fact_caching_connection *=" ./ansible.cfg | sed 's/fact_caching_connection=//g'` -if [ -d $fact_caching_connection ]; then - log "Removing $fact_caching_connection directory." - sudo rm -rf $fact_caching_connection -fi - -# Prerequisites -cmd=(ansible-galaxy collection install community.docker) -log "In directory: `pwd`." -log "Executing: ${cmd[*]}" -"${cmd[@]}" +. $APP_DIR/scripts/add-cronjob-debian.sh # Run ansible -cmd=(ansible-playbook -b -u admin 00-add-cronjob.yml) -log "In directory: `pwd`." -log "Executing: ${cmd[*]}" -"${cmd[@]}" - -cmd=(ansible-playbook -b -u admin 01-provision-all.yml) -log "In directory: `pwd`." -log "Executing: ${cmd[*]}" -"${cmd[@]}" +run_ansible() { + . $VENV_DIR/bin/activate + + cd $APP_DIR/ansible + log "In directory: `pwd`." + log "Executing: ansible-playbook -b -u $ADMIN_USERNAME amolofos.ansible_collection_workstation.p01_provision_all" + ansible-playbook -b -u $ADMIN_USERNAME amolofos.ansible_collection_workstation.p01_provision_all +} + +run_ansible cd $oldPwd diff --git a/scripts/setup-env.sh b/scripts/setup-env.sh new file mode 100755 index 0000000..116faa6 --- /dev/null +++ b/scripts/setup-env.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +set -ueo pipefail + +export ADMIN_USERNAME=${ADMIN_USERNAME:-admin} + +export APP_DIR=${APP_DIR:-/opt/automated-workstation/app} +export VENV_DIR=${VENV_DIR:-/opt/automated-workstation/.venv} + +export PYTHON_VERSION=${PYTHON_VERSION:-python3} +export PYTHON_PIP_VERSION=${PYTHON_PIP_VERSION:-pip3} +export ANSIBLE_COLLECTIONS_PATH="~/.ansible/collections" + +. $APP_DIR/scripts/utils.sh + +log "" +log "---------------------------" +log "Executing `basename \"$0\"`" +log "" + +oldPwd=`pwd` + +# Just delete any caching directory. +fact_caching_connection=`grep -E "^fact_caching_connection *=" $APP_DIR/ansible/ansible.cfg | sed 's/fact_caching_connection=//g'` +if [ -d $fact_caching_connection ]; then + log "Removing $fact_caching_connection directory." + sudo rm -rf $fact_caching_connection +fi + +# Prerequisites +prerequisites() { + $PYTHON_VERSION -m venv $VENV_DIR + . $VENV_DIR/bin/activate + + $PYTHON_PIP_VERSION install --upgrade \ + pip \ + ansible + + ansible-galaxy collection install -vvv \ + --upgrade \ + --force-with-deps \ + --collections-path $ANSIBLE_COLLECTIONS_PATH \ + --requirements-file $APP_DIR/ansible/requirements.yml +} + +log "In directory: `pwd`." +prerequisites + +cd $oldPwd diff --git a/scripts/utils.sh b/scripts/utils.sh new file mode 100755 index 0000000..3bffd94 --- /dev/null +++ b/scripts/utils.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -ueo pipefail + +log() { + echo "`date +"%Y-%m-%d %H:%M:%S"`: $1" +}