Skip to content

Commit

Permalink
Version 1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinbojko committed May 19, 2021
1 parent f25ef67 commit 71d927e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 23 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
73 changes: 56 additions & 17 deletions extra/files/gen2-linux/ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion extra/playbooks/provision_alma8_variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions extra/playbooks/provision_centos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion extra/playbooks/provision_centos7_variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions extra/playbooks/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
collections:
- name: ansible.posix
- name: community.general
- name: community.crypto
5 changes: 3 additions & 2 deletions extra/scripts/windows-compress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 71d927e

Please sign in to comment.