aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorCarlo Landmeter <clandmeter@alpinelinux.org>2018-11-16 14:28:48 +0000
committerCarlo Landmeter <clandmeter@alpinelinux.org>2018-11-16 14:28:48 +0000
commitacc448e1a6c21e47ba066c2d28adfd762345f5c7 (patch)
tree1ea03b0e5c4f496fde93d94d8900151e89c7645f /main
parent0b0f3b1d3493fb7973f57be6e445f97594e93127 (diff)
downloadaports-acc448e1a6c21e47ba066c2d28adfd762345f5c7.tar.bz2
aports-acc448e1a6c21e47ba066c2d28adfd762345f5c7.tar.xz
main/ansible: add option to change shell in lxc module
https://github.com/ansible/ansible/pull/40924
Diffstat (limited to 'main')
-rw-r--r--main/ansible/APKBUILD10
-rw-r--r--main/ansible/add-lxc-container_shell-option.patch94
2 files changed, 101 insertions, 3 deletions
diff --git a/main/ansible/APKBUILD b/main/ansible/APKBUILD
index 6f419d188a..e23d0826f9 100644
--- a/main/ansible/APKBUILD
+++ b/main/ansible/APKBUILD
@@ -4,7 +4,7 @@
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=ansible
pkgver=2.7.0
-pkgrel=0
+pkgrel=1
pkgdesc="A configuration-management, deployment, task-execution, and multinode orchestration framework"
url="https://ansible.com"
arch="noarch"
@@ -13,7 +13,10 @@ _py=py3
depends="python3 $_py-yaml $_py-paramiko $_py-jinja2 $_py-markupsafe $_py-crypto"
makedepends="python2-dev py-setuptools"
subpackages="$pkgname-doc"
-source="$pkgname-$pkgver.tar.gz::https://releases.ansible.com/ansible/$pkgname-$pkgver.tar.gz"
+source="$pkgname-$pkgver.tar.gz::https://releases.ansible.com/ansible/$pkgname-$pkgver.tar.gz
+ add-lxc-container_shell-option.patch
+ "
+
builddir="$srcdir/$pkgname-$pkgver"
# secfixes:
@@ -39,4 +42,5 @@ package() {
install -m644 README.rst "$pkgdir"/usr/share/doc/$pkgname
}
-sha512sums="a5e0e0b87bb2fa8fbc76825733a5c6afe642d4602be80466e5f28324e90be4487fd1c300e567a164222f171bd9eac65b7b36ca9b6fe4bebfcbd2c24dd60049ad ansible-2.7.0.tar.gz"
+sha512sums="a5e0e0b87bb2fa8fbc76825733a5c6afe642d4602be80466e5f28324e90be4487fd1c300e567a164222f171bd9eac65b7b36ca9b6fe4bebfcbd2c24dd60049ad ansible-2.7.0.tar.gz
+e1bd1affec585abf4556d1f2598df2689c2341fc0ddaec3eadc0a9c6df5725b8ab97092771f2c57da6ecaa72ae1bb5e5ccce55db8c4d74bfc785f611dd5b8c32 add-lxc-container_shell-option.patch"
diff --git a/main/ansible/add-lxc-container_shell-option.patch b/main/ansible/add-lxc-container_shell-option.patch
new file mode 100644
index 0000000000..93c063b7c1
--- /dev/null
+++ b/main/ansible/add-lxc-container_shell-option.patch
@@ -0,0 +1,94 @@
+From d9b11e63387aad25cf53b2de4e77e139b2102982 Mon Sep 17 00:00:00 2001
+From: lu1as <lukas.steiner@steinheilig.de>
+Date: Thu, 31 May 2018 01:25:09 +0200
+Subject: [PATCH] Add lxc `container_shell` option
+
+---
+ .../modules/cloud/lxc/lxc_container.py | 29 ++++++++++++-------
+ 1 file changed, 19 insertions(+), 10 deletions(-)
+
+diff --git a/lib/ansible/modules/cloud/lxc/lxc_container.py b/lib/ansible/modules/cloud/lxc/lxc_container.py
+index e0be3e4145db..21c7ad05610f 100644
+--- a/lib/ansible/modules/cloud/lxc/lxc_container.py
++++ b/lib/ansible/modules/cloud/lxc/lxc_container.py
+@@ -75,6 +75,11 @@
+ container_command:
+ description:
+ - Run a command within a container.
++ container_shell:
++ description:
++ - Shell used for executing *container_command*.
++ default: bash
++ version_added: "2.7"
+ lxc_path:
+ description:
+ - Place container under PATH
+@@ -166,9 +171,10 @@
+ is "stopped" and the container does not exist it will be first created,
+ "started", the command executed, and then "stopped". If you use a "|"
+ in the variable you can use common script formatting within the variable
+- iteself The "container_command" option will always execute as BASH.
+- When using "container_command" a log file is created in the /tmp/ directory
+- which contains both stdout and stderr of any command executed.
++ itself. If your container doesn't have BASH installed, you can change
++ the shell by specifying "container_shell". When using "container_command"
++ a log file is created in the /tmp/ directory which contains both stdout
++ and stderr of any command executed.
+ - If "archive" is **true** the system will attempt to create a compressed
+ tarball of the running container. The "archive" option supports LVM backed
+ containers and will create a snapshot of the running container when
+@@ -531,13 +537,12 @@
+ # container without using SSH. The template will attempt to work within the
+ # home directory of the user that was attached to the container and source
+ # that users environment variables by default.
+-ATTACH_TEMPLATE = """#!/usr/bin/env bash
+-pushd "$(getent passwd $(whoami)|cut -f6 -d':')"
++ATTACH_TEMPLATE = """#!/usr/bin/env %(container_shell)s
++cd $(getent passwd $(whoami)|cut -f6 -d':')
+ if [[ -f ".bashrc" ]];then
+ source .bashrc
+ unset HOSTNAME
+ fi
+-popd
+
+ # User defined command
+ %(container_command)s
+@@ -550,15 +555,15 @@ def create_script(command):
+ This method should be backward compatible with Python 2.4+ when executing
+ from within the container.
+
+- :param command: command to run, this can be a script and can use spacing
++ :param command: shell and command to run, this can be a script and can use spacing
+ with newlines as separation.
+- :type command: ``str``
++ :type command: ``list``
+ """
+
+ (fd, script_file) = tempfile.mkstemp(prefix='lxc-attach-script')
+ f = os.fdopen(fd, 'wb')
+ try:
+- f.write(to_bytes(ATTACH_TEMPLATE % {'container_command': command}, errors='surrogate_or_strict'))
++ f.write(to_bytes(ATTACH_TEMPLATE % {'container_shell': command[0], 'container_command': command[1]}, errors='surrogate_or_strict'))
+ f.flush()
+ finally:
+ f.close()
+@@ -940,7 +945,7 @@ def _execute_command(self):
+ elif container_state == 'stopped':
+ self._container_startup()
+
+- self.container.attach_wait(create_script, container_command)
++ self.container.attach_wait(create_script, [self.module.params.get('container_shell'), container_command])
+ self.state_change = True
+
+ def _container_startup(self, timeout=60):
+@@ -1703,6 +1708,10 @@ def main():
+ container_command=dict(
+ type='str'
+ ),
++ container_shell=dict(
++ type='str',
++ default='bash'
++ ),
+ container_config=dict(
+ type='str'
+ ),