Code Monkey home page Code Monkey logo

portable-ansible's Introduction

Self-contained Ansible distribution

Ansible package with required python modules. No need to install, just download, unpack and use. The main idea of this package is to run Ansible playbooks on local machine.

The distribution contains only ansible-base. The extra dependencies will need to be installed manually.

Changelog

All notable changes to this project are documented in the file CHANGELOG.md

How to install and use

Latest version of portable-ansible tarball (.tar.bz2) is available on Releases page https://github.com/ownport/portable-ansible/releases

wget https://github.com/ownport/portable-ansible/releases/download/<version>/portable-ansible-<version>-py3.tar.bz2 \
      -O ansible.tar.bz2

tar -xjf ansible.tar.bz2

python3 ansible localhost -m ping
 [WARNING]: provided hosts list is empty, only localhost is available

localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

Hints

If you need to run ansible playbooks, after having extracted the tarball contents run next commands to create aliases to portable ansible directory. In the examples below portable-ansible installed in /opt directory

python3 ansible-playbook playbook.yml

To have all the ansible commands, run:

for l in config console doc galaxy inventory playbook pull vault;do
  ln -s ansible ansible-$l
done

Supporting additional python packages

Install python packages into ansible/extras directory

pip3 install -t ansible/extras <package>

or

pip3 install -t ansible/extras -r requirements.txt

Instead of installing the python packages to ansible/extras, you can also install them in user directory to be available for ansible:

pip3 install --user -r requirements.txt

For developers

Please check this guideline

References

portable-ansible's People

Contributors

cyrilleverrier avatar fbnil avatar mathom avatar ownport avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

portable-ansible's Issues

ansible vault not working with encrypted password

command:
python3 ansible-playbook --vault-id root@./vault.password linuxCheckFileSystem.yml
result:
FAILED! => {"msg": "ansible-vault requires either the cryptography library (preferred) or pycrypto in order to function."}

ansible-pull failed with permission denied

Hi!
For ansible portable version 0.5 for python 3 when I run ansibe-pull like:
/usr/bin/python /opt/ent/bin/ansiblePortable/py3/ansible-pull --url https://git_repo --inventory /path_to_inv.py
i get error:
Traceback (most recent call last):
File "/opt/bin/ansiblePortable/py3/ansible-pull/main.py", line 139, in
exit_code = cli.run()
File "/opt/bin/ansiblePortable/py3/ansible/ansible/cli/pull.py", line 241, in run
rc, b_out, b_err = run_cmd(cmd, live=True)
File "/opt/bin/ansiblePortable/py3/ansible/ansible/utils/cmd_functions.py", line 44, in run_cmd
p = subprocess.Popen(cmdargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib64/python3.8/subprocess.py", line 854, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib64/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: b'/opt/bin/ansiblePortable/py3/ansible'

I can fix it by adding "cmd = 'python ' + cmd" string in def_run function in ansible/utils/cmd_functions.py like

def run_cmd(cmd, live=False, readsize=10):

    # readsize = 10
    cmd = 'python ' + cmd                                     # <<< THIS STRING
    # On python2, shlex needs byte strings
    if PY2:
         cmd = to_bytes(cmd, errors='surrogate_or_strict')
    cmdargs = shlex.split(cmd)
 
    # subprocess should be passed byte strings.  (on python2.6 it must be
    # passed byte strtings)
    cmdargs = [to_bytes(a, errors='surrogate_or_strict') for a in cmdargs]
 
    p = subprocess.Popen(cmdargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

but I think it's need to fix by more proper way.

Python 2.6 and portable-ansible-v0.4.2-py2.tar.bz2

I followed the instructions, unpacked the tarball, crested the link and run it as:

python ansible-playbook myTest.yml

This results in stack trace:

Traceback (most recent call last):
File "/usr/local/lib/python2.6/runpy.py", line 121, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/local/lib/python2.6/runpy.py", line 34, in _run_code
exec code in run_globals
File "/tmp/ZOX/ansible/main.py", line 79, in
import ansible.constants as C
File "/tmp/ZOX/ansible/ansible/constants.py", line 12, in
from jinja2 import Template
File "/tmp/ZOX/ansible/jinja2/init.py", line 9, in
from .bccache import BytecodeCache
File "/tmp/ZOX/ansible/jinja2/bccache.py", line 24, in
from .utils import open_if_exists
File "/tmp/ZOX/ansible/jinja2/utils.py", line 701
if name in {"_Namespace__attrs", "class"}:

This test script runs fine in regular ansible.

Any help to make this running?

paramiko not installed?

When trying to use paramiko to get around sshpass issue, I get the following message:

python ansible test -m ping --ask-pass -c paramiko
[DEPRECATION WARNING]: DEFAULT_SUDO_EXE option, In favor of Ansible Become, which is a generic framework. See become_exe. , use become instead. This feature will be removed in version 2.8.
Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
SSH password:
test | FAILED! => {
"msg": "paramiko is not installed"
}

Tarball building procedure

Greetings,

it is not clear how the release tarball is built with the given Makefile. From what I can see, all that the Makefile builds is a script with an embedded zipfile, that I couldn't get to work...

sshpass

Hi,

Is it possible to include sshpass as part of the build?

Thank you,

B

Ansible-vault doesn't work

Hello,

I try to use ansible-vault , but I have a mysterious problem:

first , I create a symbolic link ansible-vault to ansible

and when I try to encrypt ( or create / edit ) , I get this error,

ansible-vault 2.7.8
  config file = /opt/autom/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/ansible/ansible
  executable location = ansible-vault
  python version = 2.7.5 (default, May 31 2018, 09:41:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Using /opt/autom/ansible.cfg as config file
New Vault password:
Confirm New Vault password:
ERROR! ansible-vault requires either the cryptography library (preferred) or pycrypto in order to function.

Do have a way for fix it pls ?

thanks a lot

There are more Ansible commands now: ansible-connection and ansible-test

More of a query.
I've not come across them at work yet, but they are stubs in portable-ansible 0.5.0

They exists in: ./ansible/bin/ansible-*

There is no code for them in: ./ansible/ansible/cli/.py nor ./opt/ansible/ansible//

If you decide to add them too, then README.md might need an update:

for l in config connection console doc galaxy inventory playbook pull test vault;do
  ln -s ansible ansible-$l
done

To be honest, I'm glad the code is small and lean, and this would kind of add extra size to it.

remove Python 2.7 support

According to notice

Python 2.7 will reach the end of its life on January 1st, 2020. 
Please upgrade your Python as Python 2.7 won't be maintained after that date. 
A future version of pip will drop support for Python 2.7

there is no need to support py2.7

Support for Ansible 2.10?

Hi Ansible guys, I have been using portable-ansible recently without any problem. Until I found a needed parameter of the mysql_user module, which was new in Ansible 2.10.

Do you guys have any plan for Ansible 2.10?

"paramiko is not installed: No module named enum"

Hi @ownport , Greetings
I was trying out the released (0.3) of the portable ansible. Configured it to use paramiko as the transport , but when executing the playbook it says {"msg": "paramiko is not installed: No module named enum"}

any suggestion would be very helpful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.