diff --git a/roles/common/defaults/main.yml b/roles/common/defaults/main.yml index 78897cfdf2..d2733f04a0 100644 --- a/roles/common/defaults/main.yml +++ b/roles/common/defaults/main.yml @@ -5,7 +5,7 @@ duf_version: "0.8.1" dust_version: "0.9.0" fd_find_version: "9.0.0" configured_dependencies: [] -common_packages: +common_ubuntu_packages: - acl - build-essential - curl @@ -26,3 +26,20 @@ common_packages: - wget - zip - zlib1g-dev +common_rhel_packages: + - curl + - "@Development tools" + - git + - htop + - jq + - libacl.x86_64 + - libyaml-devel + - openssl-libs + - python3-devel + - python3-pip + - tmux + - tree + - unzip + - vim + - wget + - zip diff --git a/roles/common/molecule/default/converge.yml b/roles/common/molecule/default/converge.yml index adb0ac2c25..19d91a1bef 100644 --- a/roles/common/molecule/default/converge.yml +++ b/roles/common/molecule/default/converge.yml @@ -4,7 +4,7 @@ vars: - running_on_server: false pre_tasks: - - name: update cache + - name: Update cache ansible.builtin.apt: update_cache: true cache_valid_time: 600 diff --git a/roles/common/molecule/default/verify.yml b/roles/common/molecule/default/verify.yml index 5087782d7c..a254974196 100644 --- a/roles/common/molecule/default/verify.yml +++ b/roles/common/molecule/default/verify.yml @@ -1,28 +1,51 @@ --- - name: Verify hosts: all - gather_facts: false - tasks: - - name: check common package status - ansible.builtin.apt: - name: "{{ item }}" - state: present - check_mode: true - register: pkg_status - loop: + vars: + common_ubuntu_packages: - acl - - htop - - python3-apt - build-essential - curl - git - - unzip - - zip + - htop + - jq + - libcurl4 + - libssl-dev + - libyaml-dev + - python3-apt + - python3-pip + - python-setuptools + - silversearcher-ag - tmux + - tree + - unzip - vim - - silversearcher-ag + - wget + - zip + - zlib1g-dev + gather_facts: false + tasks: + - name: Common | Verify tmux.conf exists + ansible.builtin.stat: + path: /etc/tmux.conf + register: tmux_conf + + - name: Common | Assert tmux.conf exists + ansible.builtin.assert: + that: + - tmux_conf.stat.exists + + - name: Common | Verify vimrc exists + ansible.builtin.stat: + path: /etc/vim/vimrc.local + register: vimrc + + - name: Common | Assert vimrc exists + ansible.builtin.assert: + that: + - vimrc.stat.exists - - name: test packages are installed - ansible.builtin.assert: - that: - - not pkg_status.changed + - name: Common | Verify common Ubuntu packages are installed + ansible.builtin.apt: + name: "{{ common_ubuntu_packages }}" + state: present diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 6e38db2acc..2e1be15013 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -6,36 +6,14 @@ "ansible_hostname not in inventory_hostname" tags: "update_hostname" -- name: Common | Add apt HTTPS capabilities. - ansible.builtin.package: - name: "{{ item }}" - state: present +- name: Common | Install Common packages + ansible.builtin.include_tasks: "{{ item }}" loop: - - ca-certificates - - apt-transport-https + - ubuntu.yml + - rockylinux.yml when: - - ansible_os_family == "Debian" - -- name: Common | install snapd - ansible.builtin.package: - name: "{{ item }}" - state: present - loop: - - snapd - when: running_on_server - -- name: Common | Install procs - community.general.snap: - name: - - procs - when: running_on_server - -- name: Common | install building software and build essentials - ansible.builtin.package: - name: "{{ item }}" - state: present - update_cache: true - with_items: "{{ common_packages }}" + - item is defined + - item is not none - name: Common | copy tmux.conf ansible.builtin.template: @@ -79,15 +57,11 @@ state: present - name: Common | install duf - ansible.builtin.apt: - deb: "{{ duf_url }}/v{{ duf_version }}/duf_{{ duf_version }}_linux_amd64.deb" - register: duf_repo - retries: 3 - delay: 60 - until: duf_repo is succeeded + ansible.builtin.package: + state: present when: - - running_on_server - - ansible_os_family == "Debian" + - ansible_distribution == "Ubuntu" + - ansible_distribution_release == "jammy" - name: Common | install dust ansible.builtin.apt: @@ -97,9 +71,12 @@ - ansible_os_family == "Debian" - name: Common | install fdfind - ansible.builtin.apt: - deb: "{{ fd_find_url }}/v{{ fd_find_version }}/fd_{{ fd_find_version }}_amd64.deb" - when: running_on_server + ansible.builtin.package: + name: fd-find + state: present + when: + - ansible_os_family == "Debian" + - running_on_server - name: Common | install plocate (jammy) ansible.builtin.apt: @@ -109,5 +86,5 @@ - ansible_distribution =="Ubuntu" and ansible_distribution_release == "jammy" - name: Common | install vector, but not in testing - include_tasks: vector.yml + ansible.builtin.include_tasks: vector.yml when: running_on_server diff --git a/roles/common/tasks/rockylinux.yml b/roles/common/tasks/rockylinux.yml new file mode 100644 index 0000000000..713250edde --- /dev/null +++ b/roles/common/tasks/rockylinux.yml @@ -0,0 +1,9 @@ +--- +- name: Install common packages for Rocky Linux + ansible.builtin.package: + name: "{{ item }}" + state: present + use: dnf + loop: "{{ common_rhel_packages }}" + when: + - ansible_os_family == "RedHat" diff --git a/roles/common/tasks/ubuntu.yml b/roles/common/tasks/ubuntu.yml new file mode 100644 index 0000000000..42b3ada54b --- /dev/null +++ b/roles/common/tasks/ubuntu.yml @@ -0,0 +1,7 @@ +--- +- name: Install common packages for Ubuntu + ansible.builtin.package: + name: "{{ common_ubuntu_packages }}" + state: present + when: + - ansible_os_family == "Debian"