diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a09c56df5c7fd744f3166e151ae91dd41e57fec9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..876a61351680dd38061c84479cd227d5ae2c6c30 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,36 @@ +# VARIABLES +variables: + DOCKER_BUILDKIT: 1 + DOCKER_DRIVER: overlay2 + DOCKER_HOST: tcp://localhost:2375 + DOCKER_TLS_CERTDIR: "" + +########################################################################################################## + +## PIPELINE DEFINITION +stages: + - check + +########################################################################################################## + +### COMMON SECTION +.common: &common + services: + - registry.cyberbrain.pw/docker/dind + variables: + GIT_DEPTH: 1 + ANSIBLE_FORCE_COLOR: "True" + before_script: + - chmod -R o-w ../ + +########################################################################################################## + +### TEST SECTION +test: + <<: *common + stage: check + image: registry.cyberbrain.pw/ansible/ansible + except: + - /^master$/ + script: + - find . -type d -exec ansible-lint --force-color -v -x '204' {} \; diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..f20daf1d043c5afbb3facf32999711ac6f632712 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,65 @@ +galaxy_info: + author: Dmitriy Safronov <zimniy@cyberbrain.pw> + description: Essential configuration +# company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + issue_tracker_url: https://gitlab.cyberbrain.pw/ansible/roles/essential/-/issues + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: LGPL-2.0-or-later + + min_ansible_version: 2.9 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + platforms: + - name: Ubuntu + versions: + - focal + - bionic + - name: Linux Mint + versions: + - ulyana + - tricia + - name: Debian + versions: + - buster + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..de5621ba70f082189ef4fdb40e5251d470e6abdf --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,24 @@ +--- + +# Ubuntu +- name: Perform specific setup for Ubuntu, Debian & Linux Mint + include_tasks: ubuntu/main.yml + when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian' or ansible_distribution == 'Linux Mint' + tags: ubuntu + +######################################################################################################################## +# TMUX +- name: Enable tmux on login for non-system users and root + copy: + content: | + if [[ $- == *i* ]] && [[ ${UID} -eq 0 || ${UID} -ge 1000 ]]; then + if [[ -n "$(which tmux)" ]]; then + if [[ -z "${TMUX}" ]]; then + tmux has-session -t login || exec tmux new-session -s login && exec tmux attach-session -d -t login + fi + fi + fi + dest: /etc/profile.d/tmux.sh + owner: root + group: root + mode: 0644 diff --git a/tasks/ubuntu/essential.yml b/tasks/ubuntu/essential.yml new file mode 100644 index 0000000000000000000000000000000000000000..f73ef24e62898385348a8802aab0726d44dde8a0 --- /dev/null +++ b/tasks/ubuntu/essential.yml @@ -0,0 +1,26 @@ +--- + +# APT +- name: Install aptitude & debconf-utils using apt + apt: + state: present + update_cache: yes + force_apt_get: yes + install_recommends: no + pkg: + - aptitude + - debconf-utils + +# ESSENTIAL PACKAGES +- name: Install packages + apt: + state: present + update_cache: yes + install_recommends: no + pkg: + - bash + - mawk + - sed + - grep + - rsync + - tmux diff --git a/tasks/ubuntu/main.yml b/tasks/ubuntu/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..889d89f019471a8120dfa3aa45f3dfd8ce1a73f1 --- /dev/null +++ b/tasks/ubuntu/main.yml @@ -0,0 +1,9 @@ +--- + +# REPOSITORIES +- name: Setup repositories + include_tasks: repositories.yml + +# ESSENTIAL SETUP +- name: Perform essential setup + include_tasks: essential.yml diff --git a/tasks/ubuntu/repositories.yml b/tasks/ubuntu/repositories.yml new file mode 100644 index 0000000000000000000000000000000000000000..c9bb7daecaef7cf6a77319625fbb2334d6d96f46 --- /dev/null +++ b/tasks/ubuntu/repositories.yml @@ -0,0 +1,31 @@ +--- + +# Mint +- name: Configure repositories for Linux Mint Ulyana + include_tasks: repositories/linux_mint/repositories_mint_ulyana.yml + when: ansible_distribution == 'Linux Mint' and ansible_distribution_release == 'ulyana' + tags: repositories + +- name: Configure repositories for Linux Mint Tricia + include_tasks: repositories/linux_mint/repositories_mint_tricia.yml + when: ansible_distribution == 'Linux Mint' and ansible_distribution_release == 'tricia' + tags: repositories + + +# Ubuntu +- name: Configure repositories for Ubuntu Focal + include_tasks: repositories/ubuntu/repositories_ubuntu_focal.yml + when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'focal' + tags: repositories + +- name: Configure repositories for Ubuntu Bionic + include_tasks: repositories/ubuntu/repositories_ubuntu_bionic.yml + when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'bionic' + tags: repositories + + +# Debian +- name: Configure repositories for Debian Buster + include_tasks: repositories/debian/repositories_debian_buster.yml + when: ansible_distribution == 'Debian' and ansible_distribution_release == 'buster' + tags: repositories diff --git a/tasks/ubuntu/repositories/debian/repositories_debian_buster.yml b/tasks/ubuntu/repositories/debian/repositories_debian_buster.yml new file mode 100644 index 0000000000000000000000000000000000000000..c0ea2a8576ece34598671513ed584de9b8e9ae88 --- /dev/null +++ b/tasks/ubuntu/repositories/debian/repositories_debian_buster.yml @@ -0,0 +1,48 @@ +--- + +- name: Template a file to /etc/apt/sources.list for Debian Buster + copy: + content: | + deb [arch=amd64] http://deb.debian.org/debian buster main contrib + deb [arch=amd64] http://deb.debian.org/debian buster-updates main contrib + deb [arch=amd64] http://security.debian.org/debian-security buster/updates main contrib + dest: /etc/apt/sources.list + owner: root + group: root + mode: 0644 + force: yes + +- name: Template a file to /etc/apt/sources.list.d/non-free.list for Debian Buster + copy: + content: | + deb [arch=amd64] http://deb.debian.org/debian buster non-free + deb [arch=amd64] http://deb.debian.org/debian buster-updates non-free + deb [arch=amd64] http://security.debian.org/debian-security buster/updates non-free + dest: /etc/apt/sources.list.d/non-free.list + owner: root + group: root + mode: 0644 + force: yes + when: apply_non_free is defined and apply_non_free + +- name: Template a file to /etc/apt/sources.list.d/backports.list for Debian Buster + copy: + content: | + deb [arch=amd64] http://deb.debian.org/debian buster-backports main contrib + dest: /etc/apt/sources.list.d/backports.list + owner: root + group: root + mode: 0644 + force: yes + when: apply_backports is defined and apply_backports + +- name: Template a file to /etc/apt/sources.list.d/backports_non-free.list for Debian Buster + copy: + content: | + deb [arch=amd64] http://deb.debian.org/debian buster-backports non-free + dest: /etc/apt/sources.list.d/backports_non-free.list + owner: root + group: root + mode: 0644 + force: yes + when: apply_backports is defined and apply_backports and apply_non_free is defined and apply_non_free diff --git a/tasks/ubuntu/repositories/linux_mint/repositories_mint_tricia.yml b/tasks/ubuntu/repositories/linux_mint/repositories_mint_tricia.yml new file mode 100644 index 0000000000000000000000000000000000000000..6a4a3773c508f53591ceb3a89ace1a7bd84acfc4 --- /dev/null +++ b/tasks/ubuntu/repositories/linux_mint/repositories_mint_tricia.yml @@ -0,0 +1,17 @@ +--- + +- name: Template a file to /etc/apt/sources.list.d/official-package-repositories.list for Linux Mint Tricia + copy: + content: | + deb http://mirror.yandex.ru/linuxmint-packages tricia main upstream import backport + + deb http://mirror.yandex.ru/ubuntu bionic main restricted universe multiverse + deb http://mirror.yandex.ru/ubuntu bionic-updates main restricted universe multiverse + deb http://mirror.yandex.ru/ubuntu bionic-backports main restricted universe multiverse + + deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse + deb http://archive.canonical.com/ubuntu/ bionic partner + dest: /etc/apt/sources.list.d/official-package-repositories.list + owner: root + group: root + mode: 0644 diff --git a/tasks/ubuntu/repositories/linux_mint/repositories_mint_ulyana.yml b/tasks/ubuntu/repositories/linux_mint/repositories_mint_ulyana.yml new file mode 100644 index 0000000000000000000000000000000000000000..9f8577ff3ae9e5b940fd2a66bef9225c183f3f56 --- /dev/null +++ b/tasks/ubuntu/repositories/linux_mint/repositories_mint_ulyana.yml @@ -0,0 +1,17 @@ +--- + +- name: Template a file to /etc/apt/sources.list.d/official-package-repositories.list for Linux Mint Ulyana + copy: + content: | + deb http://mirror.yandex.ru/linuxmint-packages ulyana main upstream import backport + + deb http://mirror.yandex.ru/ubuntu focal main restricted universe multiverse + deb http://mirror.yandex.ru/ubuntu focal-updates main restricted universe multiverse + deb http://mirror.yandex.ru/ubuntu focal-backports main restricted universe multiverse + + deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse + deb http://archive.canonical.com/ubuntu/ focal partner + dest: /etc/apt/sources.list.d/official-package-repositories.list + owner: root + group: root + mode: 0644 diff --git a/tasks/ubuntu/repositories/ubuntu/repositories_ubuntu_bionic.yml b/tasks/ubuntu/repositories/ubuntu/repositories_ubuntu_bionic.yml new file mode 100644 index 0000000000000000000000000000000000000000..cb54d87b8a715e947b54736620d1f3d2008060ab --- /dev/null +++ b/tasks/ubuntu/repositories/ubuntu/repositories_ubuntu_bionic.yml @@ -0,0 +1,24 @@ +--- + +- name: Template a file to /etc/apt/sources.list for Ubuntu Bionic + copy: + content: | + deb [arch=amd64] http://ru.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse + deb [arch=amd64] http://ru.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse + deb [arch=amd64] http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse + dest: /etc/apt/sources.list + owner: root + group: root + mode: 0644 + force: yes + +- name: Template a file to /etc/apt/sources.list.d/backports.list for Ubuntu Bionic + copy: + content: | + deb [arch=amd64] http://ru.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse + dest: /etc/apt/sources.list.d/backports.list + owner: root + group: root + mode: 0644 + force: yes + when: apply_backports is defined and apply_backports diff --git a/tasks/ubuntu/repositories/ubuntu/repositories_ubuntu_focal.yml b/tasks/ubuntu/repositories/ubuntu/repositories_ubuntu_focal.yml new file mode 100644 index 0000000000000000000000000000000000000000..36df51d2aba7bbd389b648d828b819bb0e07343f --- /dev/null +++ b/tasks/ubuntu/repositories/ubuntu/repositories_ubuntu_focal.yml @@ -0,0 +1,24 @@ +--- + +- name: Template a file to /etc/apt/sources.list for Ubuntu Focal + copy: + content: | + deb [arch=amd64] http://ru.archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse + deb [arch=amd64] http://ru.archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse + deb [arch=amd64] http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse + dest: /etc/apt/sources.list + owner: root + group: root + mode: 0644 + force: yes + +- name: Template a file to /etc/apt/sources.list.d/backports.list for Ubuntu Focal + copy: + content: | + deb [arch=amd64] http://ru.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse + dest: /etc/apt/sources.list.d/backports.list + owner: root + group: root + mode: 0644 + force: yes + when: apply_backports is defined and apply_backports