Ansible pip output - pip

I'm using ansible and pip with a requirements.txt. It would be nice to know the progress of the install (with respect to which requirement lines have been processed). Is there a way to know in real time what lines have been processed?

I assume, you are using the pip module to install packages on a target machine.
Due to ansible concepts there cannot be such a possibility:
Ansible is designed to automate the tasks on remote systems in a parallel way. Just imagine your playbook concerns a group of hosts (which all should install packages): How could there be a sensible output in real time?
The only thing you can do is to capture the output with register and to print it with debug, but that would be after execution.

Related

Is it possible to manage at the same time in playbook APK and APT packages managers in Ansible?

I managed to create playbooks to backup an existing running Wordpress server by installing a VM backup server on Debian, so using APT package manager in Ansible.
Now I would like to be able to use the same playbooks but for installing at the same time the backup on an Alpine linux server.
Is there a more generic way than using APT or APK modules ?
If not what would you recommend me ?
Regards,
FB
Yes, and it's called package module, check https://docs.ansible.com/ansible/2.9/modules/package_module.html
Package names, however, might be different from distro to distro, and you still will have to provide distro-specific instructions. Quoting doc:
Package names also vary with package manager; this module will not "translate" them per distro. For example libyaml-dev, libyaml-devel.
The usual way to avoid it is to create distro-specific subtasks for different os families, or distro-specific variables, which are included with some condition.

Generating manual install guide from ansible

We have ansible playbooks to automate our deployment. I've got a client that wants to do everything himself (without using ansible) and asks us for an install procedure.
Is there a way to output the steps that ansible would run, to generate an install guide?
Short version: no, unless your playbook is entirely raw:, command:, or shell: tasks, in which case "possibly"
Medium version: perhaps with ansible-playbook -vvvv --check
Long version: tell them to actually read the playbook; unlike some other systems, with ansible being described entirely by yaml files, I think it is very straightforward to look at a playbook and tell what is going to happen. Or, fire your customer because that's just a silly request.

Shade (python) module used by ansible needed but installed from yum not pip.

hi,
i am learning Openstack Newton and i'm building a lab. I have a pc which serves as controller and a Dell PowerEdge 2950 which will serve as compute node. I have another computer which will be the Ansible node. I made my first ansible playbook and tried to run it on the controller but i get an error (i need shade module installed on controlled).
Here is the problem. If i install shade using pip it messes with my openstack controller and the horizon dashboard is not accesible anymore, i get http error 500.
Is there a shade module in yum and how is it called?
thank you.
It's always better to use virtualenv to separate python contexts.
So create a virtualenv, activate it, install ansible and any necessary library (without messing up with the system python libraries) and launch ansible.
If you don't want to use ansible in a virtualenv, you can create one just for the task execution by setting ansible_python_interpreter for localhost (take a look at this answer).

how to get commands from ansible playbook

Is there a simple way how to get back what precisely ansible script(playbook) is trying to do?
E.g. I have
- name: Install required packages
yum: name={{item}} state=present
with_items:
- nmp
become: True
And I want to get:
sudo yum install nmp
That said, I want to know what commands (OS level) ansible is running.
Basically, I need the reverse process to: Ansible and Playbook. How to convert shell commands into yaml syntax?
Summarizing here the central points from comments above [1][2].
Ansible rarely runs external commands, it's mostly Python code & Python libraries being used to control hosts. Therefor, Ansible's "translation" isn't necessarily converting yum (Ansible module) usage into yum (CLI) invocations.
While you may be able to depend on the output, in some cases, by parsing for command sequences in the output of ansible-playbook -vvv foo.yml - the implementation would be flaky at best.
I'd encourage you to keep discussing on this thread what you're trying to accomplish. It's likely there is already a solution, and someone can point you to a tool that already exists.

Best way to manage local changes to Ansible Galaxy role

I am fairly new to Ansible. I am using a couple of Ansible roles that need some tweaking of specific tasks to work on CentOS 7. What is the best workflow to handle local changes to Ansible-Galaxy roles?
Here are the options I am considering:
Fork the role and make change. Downside is that I would lose the ability to grab dependencies by running Ansible-Galaxy install -r requirements.txt
File an issue with the developer on github. Downside is they may never accept my change or may take several days/weeks.
Make changes locally. Downside is I wont be able to update roles from galaxy without losing my local changes.
After reading the documentation for the ansible-galaxy command I realized I could be pointed directly at my github fork and not affect the ability to grab dependencies using Ansible-Galaxy install -r requirements.txt.
Example: Adding a github repo to requirements.yml:
# from GitHub
src: https://github.com/bennojoy/nginx

Resources