Last active
October 20, 2020 22:07
-
-
Save jdoss/26f535be5b0c0f94834c0e7103883e93 to your computer and use it in GitHub Desktop.
Python 3.8 support for Fedora CoreOS
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
FROM quay.io/fedora/fedora:32-x86_64 | |
MAINTAINER "Forem Systems Engineering <[email protected]>" | |
LABEL maintainer="Forem Systems Engineering <[email protected]>" | |
USER root | |
RUN dnf upgrade -y \ | |
&& dnf install autoconf bison curl git gzip make patch tar \ | |
wget xz file gcc-c++ bzip2-devel gdbm-devel gmp-devel glib2-devel \ | |
libcurl-devel libxml2-devel libxslt-devel libffi-devel ncurses-devel \ | |
openssl-devel readline-devel redhat-rpm-config -y \ | |
&& dnf install python3 python3-dnf python3-pip python3-libselinux ansible -y \ | |
&& dnf -y clean all \ | |
&& rm -rf /var/cache/yum | |
RUN mkdir -p /ansible/roles | |
WORKDIR /ansible/ | |
ENV ANSIBLE_VERSION 2.9.14 | |
ENV ANSIBLE_GATHERING smart | |
ENV ANSIBLE_HOST_KEY_CHECKING false | |
ENV ANSIBLE_RETRY_FILES_ENABLED false | |
ENV ANSIBLE_ROLES_PATH /ansible/roles | |
ENV ANSIBLE_SSH_PIPELINING True | |
ENTRYPOINT ["ansible-playbook"] |
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
[Unit] | |
Description=FCOS Python 3 service | |
Wants=network.target | |
After=network-online.target | |
[Service] | |
ExecStart=/usr/local/bin/fcos_python enable | |
ExecStop=/usr/local/bin/fcos_python disable | |
Type=oneshot | |
RemainAfterExit=true | |
[Install] | |
WantedBy=multi-user.target default.target |
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
#! /usr/bin/env bash | |
# The MIT License | |
# | |
# Copyright (c) 2020 Joe Doss | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in | |
# all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
# THE SOFTWARE. | |
show_help() { | |
echo | |
echo "Usage: fcos_python {enable|disable|help}" | |
exit 0 | |
} | |
case $1 in | |
enable) | |
echo "Enabling Python 3.8" | |
/usr/local/bin/podman pull quay.io/forem/ansible:2.9.14 | |
mount --bind $(/usr/local/bin/podman image mount quay.io/forem/ansible:2.9.14) /opt/ansible/ | |
ln -sfv /opt/ansible/usr/bin/python /usr/local/bin/python | |
ln -sfv /opt/ansible/usr/lib64/libpython3.8.so.1.0 /usr/local/lib/libpython3.8.so.1.0 | |
ln -sfv /opt/ansible/usr/lib64/python3.8/ /usr/local/lib/ | |
ldconfig | |
;; | |
disable) | |
echo "Disabling Python 3.8" | |
rm -f /usr/local/lib/libpython3.8.so.1.0 | |
rm -f /usr/local/bin/python | |
rm -f /usr/local/lib/python3.8 | |
ldconfig | |
umount /opt/ansible/ | |
/usr/local/bin/podman image umount quay.io/forem/ansible:2.9.14 | |
;; | |
help) | |
show_help | |
;; | |
*) | |
printf "Unknown command!" | |
show_help | |
exit 1 | |
;; | |
esac |
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
--- | |
variant: fcos | |
version: 1.0.0 | |
passwd: | |
users: | |
- name: core | |
ssh_authorized_keys: | |
- ssh-ed25519 AAAA... | |
storage: | |
directories: | |
- path: /opt/ansible | |
mode: 0755 | |
files: | |
# This uses podman image mount which is not in Podman 2.0.x. This is a 2.1-dev podman binary. | |
- path: /usr/local/bin/podman | |
mode: 0555 | |
contents: | |
source: https://joedoss.com/downloads/podman.gz | |
compression: gzip | |
verification: | |
hash: sha512-f8eb2001e6f18270ee09d00432f14d3077b80a95cd4162628732add0f49ceaacd4219f7e459cc5babd49b8d46ce632c8d839732c96e30020020f1271f7f75881 | |
- path: /usr/local/bin/fcos_python | |
mode: 0555 | |
contents: | |
inline: | | |
#!/usr/bin/env bash | |
show_help() { | |
echo | |
echo "Usage: fcos_python {enable|disable|help}" | |
exit 0 | |
} | |
case $1 in | |
enable) | |
echo "Enabling Python 3.8" | |
/usr/local/bin/podman pull quay.io/forem/ansible:2.9.14 | |
mount --bind $(/usr/local/bin/podman image mount quay.io/forem/ansible:2.9.14) /opt/ansible/ | |
ln -sfv /opt/ansible/usr/bin/python /usr/local/bin/python | |
ln -sfv /opt/ansible/usr/lib64/libpython3.8.so.1.0 /usr/local/lib/libpython3.8.so.1.0 | |
ln -sfv /opt/ansible/usr/lib64/python3.8/ /usr/local/lib/ | |
ldconfig | |
;; | |
disable) | |
echo "Disabling Python 3.8" | |
rm -f /usr/local/lib/libpython3.8.so.1.0 | |
rm -f /usr/local/bin/python | |
rm -f /usr/local/lib/python3.8 | |
ldconfig | |
umount /opt/ansible/ | |
/usr/local/bin/podman image umount quay.io/forem/ansible:2.9.14 | |
;; | |
help) | |
show_help | |
;; | |
*) | |
printf "Unknown command!" | |
show_help | |
exit 1 | |
;; | |
esac | |
- path: /etc/ld.so.conf.d/python.conf | |
mode: 0644 | |
contents: | |
inline: | | |
/usr/local/lib | |
systemd: | |
units: | |
- name: fcos-python-3.service | |
enabled: true | |
contents: | | |
[Unit] | |
Description=FCOS Python 3 service | |
Wants=network.target | |
After=network-online.target | |
[Service] | |
ExecStart=/usr/local/bin/fcos_python enable | |
ExecStop=/usr/local/bin/fcos_python disable | |
Type=oneshot | |
RemainAfterExit=true | |
[Install] | |
WantedBy=multi-user.target default.target |
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
/usr/local/lib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment