diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2021-08-26 21:31:27 -0400 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2021-08-29 01:05:29 -0400 |
commit | 83bf3c63dab980cf129dc18e87ee8ff515740995 (patch) | |
tree | 07fb26b28a727095d72af5dbee1e1ef91c2405fe /gnu/packages | |
parent | fa4c3deb8b8194415a475e86b4b3a103cde28ead (diff) | |
download | guix-83bf3c63dab980cf129dc18e87ee8ff515740995.tar.gz |
gnu: Add ansible-core.
* gnu/packages/admin.scm (ansible-core): New variable.
Diffstat (limited to 'gnu/packages')
-rw-r--r-- | gnu/packages/admin.scm | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm index 5a97cbfe3b..8b9cfea123 100644 --- a/gnu/packages/admin.scm +++ b/gnu/packages/admin.scm @@ -42,6 +42,7 @@ ;;; Copyright © 2021 David Larsson <david.larsson@selfhosted.xyz> ;;; Copyright © 2021 WinterHound <winterhound@yandex.com> ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re> +;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -134,11 +135,14 @@ #:use-module (gnu packages qt) #:use-module (gnu packages readline) #:use-module (gnu packages ruby) + #:use-module (gnu packages selinux) #:use-module (gnu packages serialization) + #:use-module (gnu packages ssh) #:use-module (gnu packages sphinx) #:use-module (gnu packages tcl) #:use-module (gnu packages terminals) #:use-module (gnu packages texinfo) + #:use-module (gnu packages time) #:use-module (gnu packages tls) #:use-module (gnu packages version-control) #:use-module (gnu packages web) @@ -2462,6 +2466,137 @@ Statsd, Librato and InfluxDB. Graphios can emit Nagios metrics to any number of supported upstream metrics systems simultaneously.") (license license:gpl2+))) +(define-public ansible-core + (package + (name "ansible-core") + (version "2.11.4") + (source + (origin + (method url-fetch) + (uri (pypi-uri "ansible-core" version)) + (sha256 + (base32 + "0jgahcv2pyc5ky0wir55a1h9q9d6rgqj60rqmvlpbj76vz1agsi2")))) + (build-system python-build-system) + (arguments + `(#:modules ((guix build python-build-system) + (guix build utils) + (ice-9 ftw)) + #:phases + (modify-phases %standard-phases + ;; Several ansible commands (ansible-config, ansible-console, etc.) + ;; are just symlinks to a single ansible executable. The ansible + ;; executable behaves differently based on the value of sys.argv[0]. + ;; This does not work well with our wrap phase, and therefore the + ;; following two phases are required as a workaround. + (add-after 'unpack 'hide-wrapping + (lambda _ + ;; Overwrite sys.argv[0] to hide the wrapper script from it. + (substitute* "bin/ansible" + (("import traceback" all) + (string-append all " +import re +sys.argv[0] = re.sub(r'\\.([^/]*)-real$', r'\\1', sys.argv[0]) +"))))) + (add-after 'install 'replace-symlinks + (lambda* (#:key outputs #:allow-other-keys) + ;; Replace symlinks with duplicate copies of the ansible + ;; executable so that sys.argv[0] has the correct value. + (define bin (string-append (assoc-ref outputs "out") "/bin")) + (with-directory-excursion bin + (for-each + (lambda (ansible-symlink) + (delete-file ansible-symlink) + (copy-file "ansible" ansible-symlink)) + (scandir "." (lambda (x) + (and (eq? 'symlink (stat:type (lstat x))) + (string-prefix? "ansible-" x) + (string=? "ansible" (readlink x))))))))) + (add-after 'unpack 'preserve-pythonpath + (lambda _ + (substitute* "test/lib/ansible_test/_internal/ansible_util.py" + (("PYTHONPATH=get_ansible_python_path\\(args\\)" all) + (string-append all "+ ':' + os.environ['PYTHONPATH']"))))) + (add-after 'unpack 'patch-paths + (lambda* (#:key inputs outputs #:allow-other-keys) + (substitute* "lib/ansible/module_utils/compat/selinux.py" + (("libselinux.so.1" name) + (string-append (assoc-ref inputs "libselinux") + "/lib/" name))) + (substitute* "test/units/modules/test_async_wrapper.py" + (("/usr/bin/python") + (which "python"))))) + (replace 'check + ;; The environment for the test suite can be tricky to get right. + ;; The environment used for Ansible's CI defined in the following + ;; Dockerfile can be used as a reference: + ;; https://raw.githubusercontent.com/ansible/ + ;; default-test-container/master/Dockerfile. + (lambda* (#:key inputs outputs tests? #:allow-other-keys) + (when tests? + ;; Otherwise Ansible fails to create its config directory. + (setenv "HOME" "/tmp") + (setenv "PATH" (string-append (getenv "PATH") ":" + (assoc-ref outputs "out") "/bin")) + (add-installed-pythonpath inputs outputs) + ;; This test module messes up with sys.path and causes many + ;; test failures. + (delete-file "test/units/_vendor/test_vendor.py") + ;; The test fails when run in the container, for reasons + ;; unknown. + (delete-file "test/units/utils/test_display.py") + ;; This test fail for reasons unknown. + (delete-file "test/units/cli/test_adhoc.py") + ;; The test suite needs to be run with 'ansible-test', which + ;; does some extra environment setup. Taken from + ;; https://raw.githubusercontent.com/ansible/ansible/\ + ;; devel/test/utils/shippable/shippable.sh. + (invoke "ansible-test" "units" "-v"))))))) + (native-inputs + `(("openssh" ,openssh) + ("openssl" ,openssl) + ("python-mock" ,python-mock) + ("python-pycrypto" ,python-pycrypto) + ("python-pytest" ,python-pytest) + ("python-pytest-forked" ,python-pytest-forked) + ("python-pytest-mock" ,python-pytest-mock) + ("python-pytest-xdist" ,python-pytest-xdist) + ("python-pytz" ,python-pytz))) + (inputs ;optional dependencies captured in wrap scripts + `(("libselinux" ,libselinux) + ("python-paramiko" ,python-paramiko) + ("python-passlib" ,python-passlib) + ("python-pexpect" ,python-pexpect) + ("sshpass" ,sshpass))) + (propagated-inputs ;core dependencies listed in egg-info/requires.txt + `(("python-cryptography" ,python-cryptography) + ("python-jinja2" ,python-jinja2) + ("python-pyyaml" ,python-pyyaml) + ("python-packaging" ,python-packaging) ;for version number parsing + ("python-resolvelib" ,python-resolvelib-0.5))) + (home-page "https://www.ansible.com/") + (synopsis "Radically simple IT automation") + (description "Ansible aims to be a radically simple IT automation system. +It handles configuration management, application deployment, cloud +provisioning, ad-hoc task execution, network automation, and multi-node +orchestration. Ansible facilitates complex changes like zero-downtime rolling +updates with load balancers. This package is the core of Ansible, which +provides the following commands: +@itemize +@item ansible +@item ansible-config +@item ansible-connection +@item ansible-console +@item ansible-doc +@item ansible-galaxy +@item ansible-inventory +@item ansible-playbook +@item ansible-pull +@item ansible-test +@item ansible-vault +@end itemize") + (license license:gpl3+))) + (define-public ansible (package (name "ansible") |