-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Move the image prep script into a template file"
- Loading branch information
Showing
9 changed files
with
166 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
deprecations: | ||
- The option ``cache_prep_commands`` from ``lxc_cache_map`` has been | ||
removed. This option has been converted to a template file within | ||
the **lxc_hosts** role. In order to set specific cache commands within | ||
the template it is recommended that deployers set | ||
``lxc_cache_prep_pre_commands`` or ``lxc_cache_prep_post_commands``. If the | ||
entire prep script needs to be overridden deployers can set | ||
``lxc_cache_prep_template`` to the full local path of the prep template and | ||
the role will use this script irrespective of the base container type. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
set -e -x | ||
|
||
{{ lxc_cache_prep_pre_commands }} | ||
|
||
mkdir -p /etc/ansible/facts.d/ | ||
rm /etc/resolv.conf || true | ||
|
||
{% for resolver in lxc_cache_prep_dns %} | ||
echo "nameserver {{ resolver }}" >> /etc/resolv.conf | ||
{% endfor %} | ||
|
||
rpm --import /etc/pki/rpm-gpg/* | ||
|
||
# The containers do not need the LXC repository (only hosts need it). | ||
rm -f /etc/yum.repos.d/thm-lxc2.0* | ||
|
||
# Prefer dnf over yum for CentOS. | ||
which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum' | ||
|
||
# Create yum/dnf transaction file and run it all at once | ||
echo "update" > /tmp/package-transaction.txt | ||
echo "install {{ lxc_cache_distro_packages | join(' ') }}" >> /tmp/package-transaction.txt | ||
echo "run" >> /tmp/package-transaction.txt | ||
$RHT_PKG_MGR -y shell /tmp/package-transaction.txt | ||
yum-complete-transaction --cleanup-only | ||
rm -f /tmp/package-transaction.txt | ||
rm -f /usr/bin/python | ||
ln -s /usr/bin/python2.7 /usr/bin/python | ||
rm /etc/machine-id || true | ||
rm /var/lib/dbus/machine-id || true | ||
rm /etc/sysctl.d/* || true | ||
echo '' > /etc/sysctl.conf | ||
touch /etc/machine-id | ||
yum clean all | ||
mkdir -p /var/backup | ||
chage -I -1 -d -1 -m 0 -M 99999 -E -1 root | ||
|
||
# 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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
set -e -x | ||
|
||
{{ lxc_cache_prep_pre_commands }} | ||
|
||
mkdir -p /etc/ansible/facts.d/ | ||
rm /etc/resolv.conf || true | ||
|
||
{% for resolver in lxc_cache_prep_dns %} | ||
echo "nameserver {{ resolver }}" >> /etc/resolv.conf | ||
{% endfor %} | ||
|
||
# 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/{{ ansible_distribution_version }}/repo/oss repo-oss | ||
zypper lr | grep -q 'repo-update' || zypper --quiet ar {{ lxc_hosts_opensuse_mirror_url }}/update/leap/{{ ansible_distribution_version }}/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 | ||
systemctl -q unmask sshd | ||
systemctl -q enable sshd | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
set -e -x | ||
|
||
{{ lxc_cache_prep_pre_commands }} | ||
|
||
mkdir -p /etc/ansible/facts.d/ | ||
rm /etc/resolv.conf || true | ||
|
||
{% for resolver in lxc_cache_prep_dns %} | ||
echo "nameserver {{ resolver }}" >> /etc/resolv.conf | ||
{% endfor %} | ||
|
||
apt-key add /root/repo.keys | ||
rm /root/repo.keys | ||
export DEBIAN_FRONTEND=noninteractive | ||
apt-get remove -y --purge snap* lxc* lxd* resolvconf* || true | ||
|
||
# Update base distribution | ||
apt-get update | ||
apt-get upgrade -y | ||
apt-get install -y {{ lxc_cache_install_debconf }} {{ lxc_cache_distro_packages | join(' ') }} | ||
apt-get upgrade -y {{ lxc_cache_install_debconf }} | ||
rm -f /usr/bin/python | ||
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 | ||
ln -s /usr/bin/python2.7 /usr/bin/python | ||
mkdir -p /root/.ssh | ||
chmod 700 /root/.ssh | ||
userdel --force --remove ubuntu || true | ||
apt-get clean | ||
mkdir -p /var/backup | ||
mkdir -p /etc/network/interfaces.d | ||
chage -I -1 -d -1 -m 0 -M 99999 -E -1 root | ||
for action in disable mask; do | ||
systemctl ${action} resolvconf.service || true | ||
systemctl ${action} systemd-networkd-resolvconf-update.path || true | ||
systemctl ${action} systemd-networkd-resolvconf-update.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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters