Questions tagged [ansible-playbook]

468 questions
4
votes
1 answer

Returning python script value and using that in the ansible task

I am new to Ansible and a bit stuck. I have a python script that returns true or false. I run this python script via ansible task. I am trying to debug the value returned by running the py script. Additionally I would want to run another task only…
Coder
  • 83
  • 1
  • 2
  • 5
3
votes
1 answer

get the checksum of a file and update another file with this checksum in ansible?

I have a file test_proc.init in a particular directory. And I have one more file desc.cmd in the same directory which has below content: set_poc 204 6 send_data_file goldy_proc.init 4e8ee8946f7a89d2eb501a752c5e3ee6ea266e5b set_poc 204…
user5447339
  • 141
  • 2
  • 6
3
votes
1 answer

Use ansible gcp modules to create Cloud NAT

I am currently struggling to configure Cloud NAT in gcp via ansible. I was able to set up the Cloud NAT as described in the documentation: https://cloud.google.com/nat/docs/gke-example with gcloud commands, doing basically the three steps create…
3
votes
2 answers

How can I replace a template file in an Ansible role?

Some Ansible roles, such as https://github.com/bertvv/ansible-role-hosts, use template files that may be a near miss for the needs of this project. When the role author has not provided a variable substitution for the name of the template, is there…
3
votes
2 answers

How do I let Ansible show the diff of a newly created file in check mode?

Let's say I manage file myfile.conf with Ansible, e.g.: - template: src: "myfile.conf.j2" dest: "/etc/myfile.conf" I can then see the diff in a dry-run, like this: $ ansible-playbook --check --diff myplaybook.yaml Cool. But it seems to…
gertvdijk
  • 3,504
  • 4
  • 30
  • 46
3
votes
1 answer

Ansible: Loop over registered output in the next task

Ansible version: ansible 2.6.2 python version 2.7.5 I am struggling to loop over registered IP addresses from one task in other using with_items and have a debug output from an ansible playbook which gives this: The playbook: - name: Check DVS…
3
votes
1 answer

Using Ansible, how can I take actions on each file in a specific location?

I'm building playbooks to deploy a Windows application that requires some prerequisites (Visual C++ runtimes and dotNet framework) to be installed before the application itself. These prerequisites are .EXE files and are all contained in a specific…
GuillaumeN
  • 33
  • 6
3
votes
1 answer

Ansible multiline results and loop

Im registering with Ansible output from network checking in such way: - name: Test kube networking shell: kubectl exec -n iperf -it {{ item }} /test.sh loop: "{{ pods.stdout_lines }}" register: echo - debug: msg={{ item.stdout_lines }} …
user3069488
  • 169
  • 2
  • 4
  • 19
3
votes
1 answer

Ansible where do PreferredAuthentications SSH settings come from?

I'm running a standard ansible (v2.3.1) playbook using SSH username and password settings. When using the '-vvvv' setting i can see these SSH commands getting generated EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o…
emeraldjava
  • 188
  • 1
  • 7
3
votes
2 answers

How can I set the content of a variable to the result of a HTTP call?

I am attempting to query artifactory to find the latest version matching a given glob pattern. I'd like to set the output of this to a variable that I can later use with the maven_artifact module. I was thinking of a lookup, but this is performed on…
Brett Ryan
  • 327
  • 1
  • 4
  • 15
3
votes
2 answers

Ansible: run play only if tagged with specific tag

Using Ansible ansible 2.4.2.0 I'm trying to run only a certain play from the main playbook (main.yml) --- # main playbook for cluster deployment # initial configuration of OS same for all hosts - name: Cluster Deployer playbook hosts: all …
Matija B
  • 31
  • 1
  • 1
  • 3
3
votes
2 answers

Ansible: leave password unchanged when not set

I'm trying to create a set of users in Ansible using with_dict. The problem is sometimes the user already exists and I don't have the password. In that case I'd like to simply skip setting the password, but manage the rest of the user attributes. …
ebarrere
  • 330
  • 1
  • 3
  • 15
3
votes
1 answer

Ansible JSON Output

Could you please help me fetch Ansible-Playbook output in a JSON Format. I do get a JSON output if I set stdout_callback variable as "json" in ansible.cfg But that output is not in realtime. The result is shown when the whole playbook is executed.…
Akshay
  • 123
  • 1
  • 2
  • 5
3
votes
1 answer

Deploy application from local git repository

This is a two-fold question. In scenarios where the git repository is not publicly accessible, can I deploy from a local machine (that also runs Ansible) to a remove host using the local copy of the repository on my hard drive (or a copy on the…
user66336
3
votes
2 answers

Ansible print hostnames / variables in list / table

Is there a way with Ansible to print out a simple table style output. I've got the values I need registered to a variable in the playbook I just want to print it out more cleanly. Currently the output I have with stdout.lines looks like this: ok:…
Jon Dison
  • 31
  • 1
  • 2