diff --git a/README.md b/README.md index ffb23cf21e905367adbd63dcd5c1365e72334754..961cb5357a9c9f312eaa3fb702cb7a9cfd13e97e 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,22 @@ -# Workstation configuration with CentOS 7 +# An attempt to automate personal CentOS 8 workstation config Go through the following steps to configure a CentOS 7 workstation. -### Install Ansible and packages required to install Ansible +## Structure +The way this setup is structured probably does not conform with ansible best practice suggestions. Enabling or disabling a feature is controlled via tags, no roles are defined. +## Steps to follow +* Start with a minimal CentOS 8 installation. +* Install ansible and dependencies ``` yum install epel-release yum check-update yum install ansible -yum install git ``` -### Run ansible-pull +* Either run ansible-pull, which will make use of `local.yml`: ``` -ansible-pull -U <repo-url> --checkout '<branch>' +ansible-pull -U <repo-url> --checkout '<branch>' --tags <tags> ``` -### Items to add - notes -**Enable PowerTools for KDE** -```dnf config-manager --enable PowerTools``` -bash-completion -dnf -y groupinstall kde-desktop -```systemctl set-default graphical.target``` -```systemctl enable sddm -f``` -dnf -y groupinstall "Development Tools" -mesa-libGL-devel -qt5-devel -extra-cmake-modules -kf5-kconfigwidgets-devel -kdecoration-devel -kf5-ki18n-devel -kf5-kguiaddons-devel -kf5-kwindowsystem-devel - -### Plasma Configuration Saver -spectacle -kdialog - -### Before customization -https://github.com/ishovkun/SierraBreeze -(kf5-devel libs should be installed beforehand) - -### Latte dock -kf5-kactivities-devel -kf5-karchive-devel -kf5-kcrash-devel -kf5-kdeclarative-devel -kf5-kglobalaccel-devel -kf5-kiconthemes-devel -kf5-kio-devel -kf5-knewstuff-devel -kf5-knotifications-devel -kf5-plasma-devel -kf5-kwayland-devel -kf5-kdbusaddons-devel -xcb-util-devel -libSM-devel -app/view/contextmenu.h , add #include <QPointer> -https://github.com/KDE/latte-dock - -### Chrome -dnf install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm - -### Install fira code -look git script - -### Other packages -okular - -(activate Raven repository to get Kmail) -kmail -korganizer +* Or clone the repository: +``` +# ansible-playbook --tags <tags> playbook.yml +``` -### TODO -fonts: - ms fonts - consolas diff --git a/files/anaconda_module.lua b/files/anaconda_module.lua new file mode 100644 index 0000000000000000000000000000000000000000..d043c1352801d077d8c052d9d32f5d6ecdea3358 --- /dev/null +++ b/files/anaconda_module.lua @@ -0,0 +1,47 @@ +-- -*- lua -*- + +help([[ anaconda3/2020.02]]) + +-- information +whatis("Name : anaconda3 2020.02, python 3.7.6") +whatis("Version : anaconda3 2020.02") +whatis("Category : compiler") +whatis("Description : python environment") +whatis("URL : http://www.continuum.io/ ") +whatis("Installed on : 15/07/2020") + +-- family +family("python") + +-- local variables +local version = "2020.02" +local base = "/opt/anaconda3/2020.02" + +-- set environment +setenv("ANACONDA_ROOT",base) +prepend_path("PATH",pathJoin(base,"bin")) + +-- source initialization script (sh or csh) +execute{cmd="source " .. base .. "/etc/profile.d/conda."..myShellType(),modeA={"load"}} + +-- unload +if (myShellType() == "csh") then + cmd = "unsetenv CONDA_EXE; unsetenv _CONDA_ROOT; unsetenv _CONDA_EXE; " .. + "unsetenv CONDA_SHLVL; unalias conda" + execute{cmd=cmd, modeA={"unload"}} +end + +if (myShellType() == "sh") then + -- bash sets environment variables, shell functions and path to condabin + if (mode() == "unload") then + remove_path("PATH", pathJoin(base,"condabin")) + end + cmd = "unset CONDA_EXE; unset _CE_CONDA; unset _CE_M; " .. + "unset -f __conda_activate; unset -f __conda_reactivate; " .. + "unset -f __conda_hashr; unset CONDA_SHLVL; unset _CONDA_EXE; " .. + "unset _CONDA_ROOT; unset -f conda" + execute{cmd=cmd, modeA={"unload"}} +end + +-- messages +LmodMessage("Lmod: ", mode().."ing", myModuleName(), "/", myModuleVersion()) diff --git a/files/sudoers_ansible b/files/sudoers_ansible deleted file mode 100644 index 98883937ae34967f999fd11c8f4633e028a892e9..0000000000000000000000000000000000000000 --- a/files/sudoers_ansible +++ /dev/null @@ -1 +0,0 @@ -ansible ALL=(ALL) NOPASSWD: ALL diff --git a/local.yml b/local.yml index 0fdd0d551f0bdc8314537bfe26f4a9da981b29b3..93031d082952b2ba40cf7f8c68a88b2babe3c28b 100644 --- a/local.yml +++ b/local.yml @@ -1,3 +1,5 @@ +# Part of CentOS 8 workstation configuration automation files + - hosts: localhost become: true pre_tasks: @@ -6,12 +8,11 @@ changed_when: False tasks: - - include: tasks/users.yml - include: tasks/additional_repositories.yml - - include: tasks/install_kde.yml + - include: tasks/kde.yml - include: tasks/packages.yml - include: tasks/profile_settings.yml - include: tasks/kde_customization.yml - include: tasks/vim.yml - include: tasks/anaconda.yml - - include: tasks/environment_modules.yml + - include: tasks/lmod.yml diff --git a/playbook.yml b/playbook.yml new file mode 100644 index 0000000000000000000000000000000000000000..3a1bdb9c872ce93f0837f7c951a0262e441b0b87 --- /dev/null +++ b/playbook.yml @@ -0,0 +1,18 @@ +# Part of CentOS 8 workstation configuration automation files + +- hosts: all + become: true + pre_tasks: + - name: update_repositories + dnf: update_cache=yes + changed_when: False + + tasks: + - include: tasks/additional_repositories.yml + - include: tasks/kde.yml + - include: tasks/packages.yml + - include: tasks/profile_settings.yml + - include: tasks/kde_customization.yml + - include: tasks/vim.yml + - include: tasks/anaconda.yml + - include: tasks/lmod.yml diff --git a/tasks/additional_repositories.yml b/tasks/additional_repositories.yml index 7a6f863937c87ebd6db21ce4b09f0a3f24beadab..cedae791c10095d1df0b2af6f3517f810dcbcc29 100644 --- a/tasks/additional_repositories.yml +++ b/tasks/additional_repositories.yml @@ -1,4 +1,5 @@ # Enable additional software repositories +# Part of CentOS 8 workstation configuration automation files - block: @@ -7,6 +8,11 @@ name: epel-release state: latest + - name: Enable ELRepo Repository + dnf: + name: 'https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm' + state: latest + - name: Enable Raven Repository dnf: name: 'https://pkgs.dyn.su/el8/base/x86_64/raven-release-1.0-1.el8.noarch.rpm' @@ -21,4 +27,4 @@ dest: '/etc/yum.repos.d/TurboVNC.repo' tags: - - enable_repos + - enable_additional_repositories diff --git a/tasks/anaconda.yml b/tasks/anaconda.yml index e2c7d8173e320366908f336f3a43e4a6016259f3..ab822287766295ae1abc27a861d572fe4a1ec5cf 100644 --- a/tasks/anaconda.yml +++ b/tasks/anaconda.yml @@ -1,27 +1,34 @@ -# Installation of anaconda (system wide) +# System wide installation of anaconda3 +# Part of CentOS 8 workstation configuration automation files - block: - - name: check if installer already exists + - name: Presence check: anaconda3 installer stat: path: '/tmp/anaconda_installer.sh' register: anaconda_installer_exists - - name: download installer + - name: Download: anaconda3 installer get_url: url: '{{ anaconda_installer_url }}' dest: '/tmp/anaconda_installer.sh' when: not anaconda_installer_exists.stat.exists - - name: install + - name: Installation check: anaconda3 + stat: + path: '{{ anaconda_installation_path }}' + register: anaconda_installed + + - name: Installation: anaconda3 shell: 'bash anaconda_installer.sh -b -p {{ anaconda_installation_path }}' args: chdir: '/tmp' creates: '{{ anaconda_installation_path }}' + when: not anaconda_installed.stat.exists tags: - anaconda vars: anaconda_installer_url: 'https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh' - anaconda_installation_path: '/opt/anaconda' + anaconda_installation_path: '/opt/anaconda3/2020.02' diff --git a/tasks/cron.yml b/tasks/cron.yml deleted file mode 100644 index 3acaa7eae695da640a1e374c34400a61a6de6044..0000000000000000000000000000000000000000 --- a/tasks/cron.yml +++ /dev/null @@ -1,2 +0,0 @@ -- name: install cron job (ansible-pull) - cron: user="ansible" name="ansible provision" minute="*/10" job="/usr/bin/ansible-pull -o -U https://github.com/m0rningl0rd/workstation-centos7.git --checkout 'dev' > /dev/null" diff --git a/tasks/environment_modules.yml b/tasks/environment_modules.yml deleted file mode 100644 index 5621e1fb1baa6061997f39bcfd719c110f5c2ceb..0000000000000000000000000000000000000000 --- a/tasks/environment_modules.yml +++ /dev/null @@ -1,88 +0,0 @@ -# Environment modules -# TODO: Installation detection - -# Lua -- block: - - - name: download - get_url: - url: https://sourceforge.net/projects/lmod/files/lua-{{ lua_version }}.tar.bz2 - dest: /tmp/lua-{{ lua_version }}.tar.bz2 - - - name: extract - unarchive: - src: /tmp/lua-{{ lua_version }}.tar.bz2 - dest: /tmp/ - - - name: configure - shell: ./configure --prefix={{ lua_prefix }} - args: - chdir: /tmp/lua-{{ lua_version }} - creates: config.log - - - name: make - make: - chdir: /tmp/lua-{{ lua_version }} - - - name: install - make: - chdir: /tmp/lua-{{ lua_version }} - target: install - - tags: - - lua - - vars: - lua_version: 5.1.4.9 - lua_prefix: /opt/lua/{{ lua_version }} - -# Lmod -- block: - - - name: clone repository - git: - repo: https://github.com/{{ repo_name }} - dest: /tmp/{{ repo_name }} - update: yes - - - name: configure - shell: > - ./configure - --prefix={{ lmod_prefix }} - --with-module-root-path={{ lmod_modules_root }} - --with-spiderCacheDir={{ lmod_spider_cache_dir }} - --with-updateSystemFn={{ lmod_spider_cache_stamp }} - args: - chdir: /tmp/{{ repo_name }} - creates: config.log - - - name: make - make: - chdir: /tmp/{{ repo_name }} - - - name: install - make: - chdir: /tmp/{{ repo_name }} - target: install - - - name: create bash profile link - file: - src: '{{ lmod_prefix }}/lmod/lmod/init/profile' - dest: '/etc/profile.d/z00_lmod.sh' - state: link - - - name: create zsh profile link - file: - src: '{{ lmod_prefix }}/lmod/lmod/init/cshrc' - dest: '/etc/profile.d/z00_lmod.csh' - state: link - - tags: - - lmod - - vars: - repo_name: 'TACC/Lmod' - lmod_prefix: '/opt' - lmod_modules_root: '/opt/modules' - lmod_spider_cache_dir: '{{ lmod_modules_root }}/.spider-cache' - lmod_spider_cache_stamp: '{{ lmod_modules_root }}/.spider-cache.stamp' diff --git a/tasks/install_kde.yml b/tasks/install_kde.yml deleted file mode 100644 index 29fd447f9a87ad23836364f655bfe91437390a4f..0000000000000000000000000000000000000000 --- a/tasks/install_kde.yml +++ /dev/null @@ -1,9 +0,0 @@ -- name: Install KDE Plasma - dnf: - name: '@kde-desktop' - state: present - -# Below item(s) do not work, need to execute manually -# - name: Enable KDE Plasma -# command: systemctl set-default graphical.target -# command: systemctl enable sddm -f diff --git a/tasks/kde.yml b/tasks/kde.yml new file mode 100644 index 0000000000000000000000000000000000000000..12322eb6ab6951d9adca131f90281cfbfe59959b --- /dev/null +++ b/tasks/kde.yml @@ -0,0 +1,18 @@ +# Installation of KDE Plasma +# Part of CentOS 8 workstation configuration automation files + +- name: Install KDE Plasma + dnf: + name: '@kde-desktop' + state: present + tags: + - kde + +- name: Display information message + debug: + msg: + - 'Below commands should be executed manually:' + - 'systemctl set-default graphical.target' + - 'systemctl enable sddm -f' + tags: + -kde diff --git a/tasks/kde_customization.yml b/tasks/kde_customization.yml index 5b19af761c485ff9a10979fde5193751c931e4d1..5200d08729787173ef49f8ca1671856e0f0784ea 100644 --- a/tasks/kde_customization.yml +++ b/tasks/kde_customization.yml @@ -1,29 +1,29 @@ # Stuff related to KDE customization +# Part of CentOS 8 workstation configuration automation files # SierraBreeze icon set -- name: SierraBreezeEnhanced installation check +- name: Installation check: SierraBreezeEnhanced stat: path: '/usr/lib/libsierrabreezeenhancedcommon5.so.0' register: sierra_breeze_installed tags: - - test - kde_customization - block: - - name: clone repository + - name: Clone repository: SierraBreezeEnhanced git: repo: '{{ repo_name }}' dest: '{{ tmp_dir }}' update: yes - - name: create build directory + - name: Create build directory: SierraBreezeEnhanced file: path: '{{ tmp_dir }}/build' state: directory recurse: no - - name: cmake + - name: cmake: SierraBreezeEnhanced shell: > cmake .. -DCMAKE_INSTALL_PREFIX=/usr @@ -35,23 +35,22 @@ chdir: '{{ tmp_dir }}/build' creates: '{{ tmp_dir }}/build/Makefile' - - name: make + - name: make: SierraBreezeEnhanced make: chdir: '{{ tmp_dir }}/build' - - name: install + - name: Installation: SierraBreezeEnhanced make: chdir: '{{ tmp_dir }}/build' target: install - - name: cleanup + - name: Cleanup: SierraBreezeEnhanced file: path: '{{ tmp_dir }}' state: absent tags: - kde_customization - - test vars: repo_name: 'https://github.com/m0rningl0rd/SierraBreezeEnhanced' @@ -60,42 +59,60 @@ when: not sierra_breeze_installed.stat.exists # Latte Dock -# TODO: Execute only when produced libraries are not present -# TODO: Somehow log output of make & cmake commands +- name: Installation check: latte-dock + stat: + path: '/usr/bin/latte-dock' + register: latte_dock_installed + tags: + - kde_customization + - block: - - name: Clone repository + - name: Clone repository: latte-dock git: - repo: https://github.com/{{ repo_name }} - dest: /tmp/{{ repo_name }} + repo: '{{ repo_name }}' + dest: '{{ tmp_dir }}' update: yes - - name: Create build directory + - name: Create build directory: latte-dock file: - path: /tmp/{{ repo_name }}/build + path: '{{ tmp_dir }}/build' state: directory recurse: no - - name: Build - command: cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DKDE_L10N_AUTO_TRANSLATIONS=OFF + - name: cmake: latte-dock + shell: > + cmake .. + -DCMAKE_INSTALL_PREFIX=/usr + -DCMAKE_BUILD_TYPE=Release + -DKDE_L10N_AUTO_TRANSLATIONS=OFF args: - chdir: /tmp/{{ repo_name }}/build + chdir: '{{ tmp_dir }}/build' - - name: Install - command: make install - args: - chdir: /tmp/{{ repo_name }}/build + - name: make: latte-dock + make: + chdir: '{{ tmp_dir }}/build' + + - name: Installation: latte-dock + make: + chdir: '{{ tmp_dir }}/build' + target: install + + - name: Cleanup: latte-dock + file: + path: '{{ tmp_dir }}' + state: absent tags: - kde_customization vars: - repo_name: m0rningl0rd/latte-dock + repo_name: 'https://github.com/m0rningl0rd/latte-dock' + tmp_dir: '/tmp/latte-dock' -# Fira fonts +# FiraCode font family # TODO: Check if already installed, even though it is checked in the script -- name: Install Fira Code font family - become: yes +- name: Installation: FiraCode font family shell: files/install-fira-fonts.sh tags: - kde_customization diff --git a/tasks/lmod.yml b/tasks/lmod.yml new file mode 100644 index 0000000000000000000000000000000000000000..7bb131893d69274ccb69fa91da217e55d24ff315 --- /dev/null +++ b/tasks/lmod.yml @@ -0,0 +1,85 @@ +# Lmod environment management +# Part of CentOS 8 workstation configuration automation files + +- name: Installation check: Lmod + stat: + path: '/opt/lmod/lmod' + register: lmod_installed + tags: + - lmod + +- block: + + - name: Clone repository: Lmod + git: + repo: '{{ repo_name }}' + dest: '{{ tmp_dir }}' + update: yes + + - name: Configure: Lmod + shell: > + ./configure + --prefix={{ lmod_prefix }} + --with-module-root-path={{ lmod_modules_root }} + --with-spiderCacheDir={{ lmod_spider_cache_dir }} + --with-updateSystemFn={{ lmod_spider_cache_stamp }} + args: + chdir: '{{ tmp_dir }}' + creates: 'config.log' + + - name: make: Lmod + make: + chdir: '{{ tmp_dir }}' + + - name: Installation: Lmod + make: + chdir: '{{ tmp_dir }}' + target: install + + - name: Link: Lmod bash profile + file: + src: '{{ lmod_prefix }}/lmod/lmod/init/profile' + dest: '/etc/profile.d/z00_lmod.sh' + state: link + + - name: Link: Lmod zsh profile + file: + src: '{{ lmod_prefix }}/lmod/lmod/init/cshrc' + dest: '/etc/profile.d/z00_lmod.csh' + state: link + + - name: Create modulefiles directory + file: + path: '{{ lmod_modules_root }}' + state: directory + owner: root + group: root + mode: '0755' + + - name: Setup .modulespath file + shell: 'echo {{ lmod_modules_root }} >> {{ lmod_prefix }}/lmod/lmod/init/.modulespath' + args: + creates: '{{ lmod_prefix }}/lmod/lmod/init/.modulespath' + + - name: File permissions: .modulespath + file: + path: '{{ lmod_prefix }}/lmod/lmod/init/.modulespath' + owner: root + group: root + mode: '0644' + + - name: Cleanup: Lmod + file: + path: '{{ tmp_dir }}' + state: absent + + tags: + - lmod + + vars: + repo_name: 'https://github.com/TACC/Lmod' + tmp_dir: '/tmp/lmod' + lmod_prefix: '/opt' + lmod_modules_root: '/opt/modules' + lmod_spider_cache_dir: '{{ lmod_modules_root }}/.spider-cache' + lmod_spider_cache_stamp: '{{ lmod_modules_root }}/.spider-cache.stamp' diff --git a/tasks/packages.yml b/tasks/packages.yml index 0b5a427696d94c9b790edbc00dd2cc52896d6105..18af0c6e73c0bed2a04e321e886b2e4d4b650122 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -1,3 +1,6 @@ +# Install required packages +# Part of CentOS 8 workstation configuration automation files + - name: install packages tags: - packages @@ -6,6 +9,7 @@ - '@Development Tools' - htop - tmux + - git - glibc-all-langpacks - bash-completion - mesa-libGL-devel @@ -74,5 +78,29 @@ - perl-ExtUtils-Embed - turbovnc - fuse-sshfs + - glibc.i686 + - glib2.i686 + - bzip2-libs.i686 + - libpng.i686 + - libtiff.i686 + - libXft.i686 + - libXxf86vm.i686 + - sssd-client.i686 + - libpng12 + - libpng12.i686 + - libXp + - libXp.i686 + - openmotif + - zlib + - redhat-lsb + - compat-libtiff3 + - xorg-x11-fonts-cyrillic + - xorg-x11-fonts-ISO8859-1-75dpi + - xterm + - libstdc++.i686 + - libstdc++-devel.i686 + - gtk2.i686 + - libSM.i686 + - libXt.i686 state: present update_cache: True diff --git a/tasks/profile_settings.yml b/tasks/profile_settings.yml index 13ef0c63ebcaeae7434f95d6059a80f74b95b232..e5c31810e7668e32b7ad9354b2ba5a8cd47ecc76 100644 --- a/tasks/profile_settings.yml +++ b/tasks/profile_settings.yml @@ -1,21 +1,22 @@ # Modifications in /etc/profile.d +# Part of CentOS 8 workstation configuration automation files -# JAVA -# TODO: The java version name is hradcoded in java.sh, needs care -- name: java profile installation check +# java +# TODO: The java path is hardcoded in java.sh, needs care +- name: Installation check: /etc/profile.d/java.sh stat: path: '/etc/profile.d/java.sh' register: java_profile_installed tags: - profile_settings -- name: show information +- name: Show information debug: msg: '{% if java_profile_installed.stat.exists %} Java profile already installed. {% else %} Java profile not installed, proceeding with installation.. {% endif %}' tags: - profile_settings -- name: java profile +- name: Installation: /etc/profile.d/java.sh copy: src=files/java.sh dest=/etc/profile.d/java.sh when: not java_profile_installed.stat.exists tags: diff --git a/tasks/users.yml b/tasks/users.yml deleted file mode 100644 index b13ee337d18f1ba1b39c57b5a29de88897bd5af0..0000000000000000000000000000000000000000 --- a/tasks/users.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: create ansible user - user: name=ansible uid=900 - -- name: copy sudoers ansible - copy: src=files/sudoers_ansible dest=/etc/sudoers.d/ansible owner=root group=root mode=0440 diff --git a/tasks/vim.yml b/tasks/vim.yml index 70ff0297107ec30cefe1f90c2dc8e45c1f455b67..f98042f1557d1bd6d96874e7e4372416dd6486c4 100644 --- a/tasks/vim.yml +++ b/tasks/vim.yml @@ -1,15 +1,23 @@ # Build and install latest release of vim from official repository +# Part of CentOS 8 workstation configuration automation files + +- name: Installation check: vim + stat: + path: '/usr/local/bin/vim' + register: vim_installed + tags: + - vim - block: - - name: clone repository + - name: Clone repository: vim git: repo: '{{ repo_name }}' dest: '{{ tmp_dir }}' update: yes # First command was required to fix missing configure features related to rubyinterp - - name: configure + - name: Configure: vim shell: > eval $(rpmbuild --eval '%{configure}' | egrep '^\s*[A-Z]+=') && ./configure @@ -23,18 +31,18 @@ --enable-tclinterp args: chdir: '{{ tmp_dir }}' - creates: src/auto/config.log + creates: 'src/auto/config.log' - - name: make + - name: make: vim make: chdir: '{{ tmp_dir }}' - - name: install + - name: Installation: vim make: chdir: '{{ tmp_dir }}' target: install - - name: cleanup + - name: Cleanup: vim file: path: '{{ tmp_dir }}' state: absent