openstack-ansible-lxc_hosts/templates/prep-scripts/opensuse_leap_prep.sh.j2
Markos Chandras 5f0f01c355 SUSE: Add support for openSUSE Leap 15
This also ensures that the OBS Virtualization repository is only created
for Leap 42.X since Leap 15.X already contains the necessary LXC
packages in the standard repos. Finally, we don't use the major version
for the Leap 15 files since there is a currently a bug in Ansible[1]
which returns 'NA' as major version for Leap 15.

This patch does not add any jobs since there is a circular dependency
with the lxc_container_create role. Once Leap 15 is supported in that
role, we will add jobs in this role as well.

[1]: https://github.com/ansible/ansible/issues/41410
Change-Id: I64e38ac7b7e8dec81b5f637301df8a112aa03d9b
2018-06-27 07:40:08 +01:00

49 lines
2.0 KiB
Django/Jinja

#!/usr/bin/env bash
set -e -x
{{ lxc_cache_prep_pre_commands }}
{% include 'templates/prep-scripts/_container_sys_setup.sh.j2' %}
# We have (tried to!) copied repo-oss and repo-update from the host so wipe everything else.
find /etc/zypp/repos.d/ -type f ! -name "repo-oss.repo" -a ! -name "repo-update.repo" -delete
zypper lr | grep -q 'repo-oss' || zypper --quiet ar {{ lxc_hosts_opensuse_mirror_url }}/distribution/leap/{{ lxc_cache_map.release }}/repo/oss repo-oss
zypper lr | grep -q 'repo-update' || zypper --quiet ar {{ lxc_hosts_opensuse_mirror_url }}/update/leap/{{ lxc_cache_map.release }}/oss repo-update
# Disable recommended packages. Only update what's really needed
if ! fgrep -qx "solver.onlyRequires = true" /etc/zypp/zypp.conf; then
echo -e "\n\n## Disable recommended packages\nsolver.onlyRequires = true" >> /etc/zypp/zypp.conf
fi
# Update base distribution
zypper --gpg-auto-import-keys -n dup --force-resolution -l
zypper --gpg-auto-import-keys -n in --force-resolution -l {{ lxc_cache_distro_packages | join(' ') }}
mkdir -p /var/backup
chage -I -1 -d -1 -m 0 -M 99999 -E -1 root
# NOTE(hwoarang): Enable sshd which has been explicitely disabled in
# https://github.com/lxc/lxc-ci/commit/8dc7105399350a59698538a12b6d5a1a880ef2ba
if systemctl list-unit-files sshd.service | egrep '(masked|disabled)'; then
systemctl -q unmask sshd
systemctl -q enable sshd
fi
rm /etc/machine-id || true
rm /var/lib/dbus/machine-id || true
touch /etc/machine-id
rm /etc/sysctl.d/* || true
echo '' > /etc/sysctl.conf
for action in disable mask; do
systemctl ${action} wicked.service || true
systemctl ${action} wickedd.service || true
systemctl ${action} wickedd-auto4.service || true
systemctl ${action} wickedd-dhcp4.service || true
systemctl ${action} wickedd-dhcp6.service || true
systemctl ${action} wickedd-nanny.service || true
done
# Set the IP of the lxcbr0 interface as the DNS server
echo "nameserver {{ lxc_net_address }}" > /etc/resolv.conf
systemctl enable systemd-networkd
{{ lxc_cache_prep_post_commands }}