diff --git a/CHANGELOG.md b/CHANGELOG.md index c58db61..d8561f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,15 @@ # Changelog +## Version 1.7.2 2021-05-19 + +* [Extra] fixed cleaning temp script for Windows, to skip current packer scripts. +* [Extra] Package `zabbix-agent` was replaced by `zabbix-agent2` in default settings, same for service +* [Extra] `ansible.sh` prepared to run on multiple ditributions + ## Version 1.7.1 2021-05-11 * [BREAKING_CHANGE] switch Puppet repository to version 6 -* Fixed `prepare_neofetch.sh` not being run in playbook +* [CentOS] Fixed `prepare_neofetch.sh` not being run in playbook ## Version 1.7.0 2021-05-11 diff --git a/README.md b/README.md index 4678093..79caf05 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ New-NetFirewallRule -DisplayName "Packer_http_server" -Direction Inbound -Action During deployment ansible-base and ansible are installed in operating system. After deployment ends, these packages are removed. Playbooks are held in `/extra/playbooks` folder, with proper OS variables. -- adjust `./variables/*.yaml` files to achieve override for ansible +- adjust `./variables/*.yml` files to achieve override for ansible ```yaml install_epel: true # install Epel diff --git a/extra/files/gen2-linux/ansible.sh b/extra/files/gen2-linux/ansible.sh index 517d370..5950615 100755 --- a/extra/files/gen2-linux/ansible.sh +++ b/extra/files/gen2-linux/ansible.sh @@ -14,34 +14,73 @@ while getopts :i: option ;; esac done +# what os we're dealing with +OS=$(grep -e '^ID_LIKE=' /etc/os-release|tr -d '"'|sed -e "s/^ID_LIKE=//"|tr "[:upper:]" "[:lower:]") -if [ "$INSTALL" == "true" ];then - yum clean all -y - yum makecache -y - yum remove ansible -y||true - yum install python3 python3-devel python3-pip python3-wheel -y - yum install python3-setuptools python3-psutil -y +if [ -z "$OS" ];then +echo "Couldn't recognise os, exiting" +exit 1 +else +echo "Found: $OS" +fi + +if [ -z "$INSTALL" ];then + usage + exit 1 +fi + +echo "Found os: $OS" + +function install_ansible { /usr/bin/python3 -m pip install --upgrade pip - /usr/bin/python3 -m pip install --upgrade jmespath jsonlint yamllint ansible-base ansible setuptools-rust + /usr/bin/python3 -m pip install --upgrade jmespath jsonlint yamllint ansible-base ansible pywinrm requests-kerberos requests-ntlm requests-credssp pypsrp /usr/local/bin/ansible-galaxy collection install ansible.posix /usr/local/bin/ansible-galaxy collection install community.general -# /usr/local/bin/ansible-galaxy collection install community.docker -# /usr/local/bin/ansible-galaxy collection install ansible.windows -# /usr/local/bin/ansible-galaxy collection install community.windows -# /usr/local/bin/ansible-galaxy collection install chocolatey.chocolatey + /usr/local/bin/ansible-galaxy collection install community.crypto +} + +if [ "$INSTALL" == "true" ] && [[ "$OS" =~ rhel|centos|fodora ]];then + echo "Installing ansible on RHEL/related" + yum clean all -y + yum makecache -y + yum remove ansible ansible-base -y||true + yum install python3 python3-devel python3-pip python3-wheel cowsay krb5-devel krb5-workstation -y + yum install python3-setuptools python3-psutil -y + /usr/bin/python3 -m pip install --upgrade setuptools-rust + install_ansible fi -if [ "$INSTALL" == "false" ];then +if [ "$INSTALL" == "false" ] && [[ "$OS" =~ rhel|centos|fedora ]];then + echo "Removing ansible on RHEL/related" yum clean all -y yum makecache -y - /usr/bin/python3 -m pip uninstall jmespath jsonlint yamllint ansible-base ansible setuptools-rust -y - rm -rf /root/.ansible||true - rm -rf /root/.cache||true + /usr/bin/python3 -m pip uninstall jmespath jsonlint yamllint ansible-base ansible setuptools-rust pywinrm requests-kerberos requests-ntlm requests-credssp pypsrp -y + rm -rfv /root/.ansible||true + rm -rfv /root/.cache||true + rm -rfv /home/vagrant/.ansible||true + rm -rfv /home/vagrant/.cache||true yum clean -y all fi -if [ -z "$INSTALL" ];then - usage +if [ "$INSTALL" == "true" ] && [[ "$OS" =~ debian|ubuntu ]];then + echo "Installing ansible on Ubuntu/Debian" + apt-get clean all -y + apt-get update -y + apt-get purge ansible ansible-base -y||true + apt-get install python3 python3-dev python3-pip python3-wheel cowsay libkrb5-dev -y + install_ansible +fi + +if [ "$INSTALL" == "false" ] && [[ "$OS" =~ debian|ubuntu ]];then + echo "Removing ansible on Ubuntu/Debian" + apt-get clean all -y + apt-get update -y + /usr/bin/python3 -m pip uninstall jmespath jsonlint yamllint ansible-base ansible pywinrm requests-kerberos requests-ntlm requests-credssp pypsrp -y + rm -rfv /root/.ansible||true + rm -rfv /root/.cache||true + rm -rfv /home/vagrant/.ansible||true + rm -rfv /home/vagrant/.cache||true fi + exit diff --git a/extra/playbooks/provision_alma8_variables.yml b/extra/playbooks/provision_alma8_variables.yml index af3dc60..05f5a91 100644 --- a/extra/playbooks/provision_alma8_variables.yml +++ b/extra/playbooks/provision_alma8_variables.yml @@ -106,7 +106,7 @@ neofetch: line: ' #info "Packages" packages' timezone: "Europe/Copenhagen" remote_files: - - url: https://raw.githubusercontent.com/marcinbojko/hv-packer/master/extra/files/gen2-centos/prepare_neofetch.sh + - url: https://raw.githubusercontent.com/marcinbojko/hv-packer/master/extra/files/gen2-linux/prepare_neofetch.sh dest: /tmp/prepare_neofetch.sh mode: "0755" firewalld: diff --git a/extra/playbooks/provision_centos.yaml b/extra/playbooks/provision_centos.yaml index a054734..bb8729e 100644 --- a/extra/playbooks/provision_centos.yaml +++ b/extra/playbooks/provision_centos.yaml @@ -515,6 +515,7 @@ dev: "/dev/{{ extra_device }}1" state: present resizefs: true + opts: -L docker register: r_create_docker_filesystem when: (r_partition_docker_volume is defined and r_partition_docker_volume is success) and (r_check_for_extra_device.stat.exists and r_check_for_extra_device is defined) - name: rerun_setup diff --git a/extra/playbooks/provision_centos7_variables.yml b/extra/playbooks/provision_centos7_variables.yml index 3eff43a..a0d656c 100644 --- a/extra/playbooks/provision_centos7_variables.yml +++ b/extra/playbooks/provision_centos7_variables.yml @@ -68,7 +68,7 @@ webmin: zabbix: repository: - url: https://repo.zabbix.com/zabbix/5.2/rhel/7/x86_64/zabbix-release-5.2-1.el7.noarch.rpm - name: zabbix-agent + name: zabbix-agent2 file: /etc/yum.repos.d/zabbix.repo gpgkey: https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591 priorities: diff --git a/extra/playbooks/requirements.yaml b/extra/playbooks/requirements.yaml index 92a0244..61d9e43 100644 --- a/extra/playbooks/requirements.yaml +++ b/extra/playbooks/requirements.yaml @@ -2,3 +2,4 @@ collections: - name: ansible.posix - name: community.general + - name: community.crypto diff --git a/extra/scripts/windows-compress.ps1 b/extra/scripts/windows-compress.ps1 index d7316a2..99e5661 100755 --- a/extra/scripts/windows-compress.ps1 +++ b/extra/scripts/windows-compress.ps1 @@ -21,8 +21,9 @@ dism /online /cleanup-image /StartComponentCleanup /ResetBase dism /online /cleanup-Image /SPSuperseded # Remove leftovers from deploy -if (Test-Path -Path c:\Windows\Temp ) { - Remove-Item c:\Windows\Temp\* -Recurse -Force +if ((Test-Path -Path $env:systemroot\Temp) -and ($env:systemroot)) { + Write-Host "Cleaning :" $env:systemroot\Temp + Remove-Item $env:systemroot\Temp\* -Exclude "packer-*","script-*" -Recurse -Force -ErrorAction SilentlyContinue } # optimize disk