Questions tagged [ansible]

1

votes
2

answer
634

Views

Convert Jboss (WildFly) cli output to json in Ansible

I'm struggling to automate my deployment processes to WildFly over its cli. The cli itself don't work idempotent, so if I want to add using ansible for example some server properties it just threw an error in case it already exist (official cli documentation gives only 3 methods add, read, remove ht...
1

votes
1

answer
755

Views

Escape chars in Terraform local exec provisioner

I want to chain Terraform and Ansible using the local-exec provisioner; However since this requires input to Ansible from Terraform I am stuck with the following complex command: provisioner 'local-exec' { command = 'sleep 60; ansible-playbook -i ../ansible/inventory/ ../ansible/playbooks/site.yml -...
pkaramol
1

votes
1

answer
1.5k

Views

Ansible with Google Cloud Platform GCE

I used Ansible to create a gce cluster following the guideline at: https://docs.ansible.com/ansible/latest/scenario_guides/guide_gce.html And at the end of the GCE creations, I used the add_host Ansible module to register all instances in their corresponding groups. e.g. gce_master_ip But then when...
Tim Raynor
1

votes
2

answer
510

Views

Running “mvn clean install” maven command using ansible module

I am trying to implement the CI/CD pipeline for my project. I am using Ansible , Docker and jenkins. SVN checkout , Image docker image building , image pushing to Dockerhub , Pulling and deploying etc every stages are planning to do using ansible roles.Now I successfully implemented sample svnchecko...
Jacob
1

votes
1

answer
28

Views

Is it possible to use variable in Jinja2 default filter?

I guess it is not possible to refer to item variable when using Jinja2 'default' filter? Like in this example playbook: --- - hosts: localhost become: no gather_facts: no vars: users: - foo: name: 'foo' home: /home/foo - bar: name: 'bar' tasks: - name: debug debug: msg: '{{ item.home | default('/hom...
NemoSaltatSobrius
1

votes
1

answer
214

Views

Debug info from custom ansible module

I wrote my own ansible module in python. It is working fine, however I would like to report some information during running task (task takes a long time). I know that after execution of task, stdout is written to console. However, I would like to show some info during execution of task. Is it pos...
Docker fun
1

votes
1

answer
125

Views

Ansible aws_ec2 inventory plugin issue

I am trying to get started using Ansible and the aws_ec2 plugin. I have the following in my ./ansible.cfg file: [inventory] enable_plugins = aws_ec2 and the following in my ./inventory.yml file: plugin: aws_ec2 aws_access_key_id: ********** aws_secret_access_key: ********** regions: - us-east-2 when...
Shawn Northrop
1

votes
4

answer
155

Views

[“Shared connection closed.”], “stdout”: "sudo: a password is required\r\n while using ansible playbook

I am trying to run one ansible playbook for deploying kubernetes cluster using the tool kubespray on ubuntu 16.04 OS. I have one base machine which is installed with ansible and cloned kubespray git repository. And one master and two worker nodes containing in cluster. My host (Updated) file like t...
Jacob
0

votes
0

answer
4

Views

Not able to gather facts of ansible host machine

Set up module in ansible gives an error when i tried to set custom facts on host machine using control machine hosts: test-servers gather_facts: false tasks: name: deleting Facts directory file: path: /etc/ansible/facts.d/ state: absent name: Creates a directiory file: path: /etc/ansible/facts.d/ re...
kishan agarwal
0

votes
0

answer
2

Views

Change permissions of folder and its contents

I initially use the git module to download a repo as root user and then need to change the ownership from root to jenkins. The entire git repo and its contents are owned by root [email protected]:/usr/share/kaniko$ ls -tlrh total 172K drwxr-xr-x 9 root root 4.0K Apr 25 19:12 vendor -rwxr-xr-x 1...
Jason Stanley
0

votes
0

answer
5

Views

How to read ssh private key from the file and put it in Vault

Is there a way to read private ssh key as multiline variable from the file and put it in Vault KV secret store with Ansible? I've tried to read a key from file with lookup 'file'. It returns value as a single line with \r\n, but for using it (after retrieving from Vault), it should be a multiline (p...
m0ps
0

votes
1

answer
11

Views

How to resolve warning "Could not match supplied host pattern, ignoring: <machine hostname>?

I'm trying to use Ansible to automate my workstation. I've been following this tutorial as an introduction. But I keep getting a warning using the ansible-pull command. After doing sudo ansible-pull -U https://github.com/plsergent/setup-user-friendly.git i'm getting [WARNING]: Could not match suppli...
PL Sergent
0

votes
0

answer
5

Views

Combining lists of strings in Ansible

I have two lists of strings in Ansible: vars: pre: - one - two post: - alpha - beta I can get the cartesian product of these lists easily: set_fact: prods='{{pre|product(post)|list}}' How do I then combine the individual parts to get a list like this: prods: - one-alpha - one-beta - two-alpha - two-...
John
0

votes
0

answer
6

Views

Ansible, k8s and variables

I'm using Ansible and the k8s module for deploying applications to an OpenShift cluster. In general this is working really well. However, when I try to set the port value, in a deployment config, using a value from a variable, things are not so happy. I have the following ansible task as an example:...
Magick
1

votes
2

answer
1.5k

Views

How to fix Memory error in Ansible?

Now i m trying to copy the file from /Build_Artifacts/build.zip to /Build_Artifacts/. Permission was set to 777 for /Build_Artifacts/. while running the playbook it reports as Memory error!! cat deploy.yml hosts: '{{host}}' user: soundar tasks: - name: copying copy: src=/Build_Artifacts/build.zip d...
soundararajan.c
1

votes
1

answer
1.2k

Views

Expect timeout and return output without executing remaining commands

I am trying to run a shell script with ansible expect module which require 'n' number of response to be given, in one point I am giving a tar file name which need to be extracted by the script so it takes some time and then only i will be getting next prompt, But expect returns the output without wa...
1

votes
1

answer
502

Views

Replace character in a string with Ansible

I have this Ansible as a String: FUBAR={{ PREFIX }}_{{ CNAME }}{{ VERSION }} I want to replace all . in the concatenated string with '', like this: FUBAR={{ {{ PREFIX }}_{{ CNAME }}{{ VERSION }} | replace('.','') }} I get the message: expected token ':', got '}' Could anyone give me a suggestion wha...
Stefan Beike
1

votes
3

answer
69

Views

Wrong result when evaluating multi-line boolean variable in Ansible yaml file

Using ansible 2.7.5 I am trying to create a multi-line boolean parameter. I first verified that it works as expected as one-line with: FOOD: apple IS_FRUIT: '{% if FOOD == 'carrot' %}false{% elif FOOD == 'apple' or FOOD == 'banana' %}true{% endif %}' and then a task: - name: 'FOOD is: {{ FOOD }}' d...
u123
1

votes
1

answer
49

Views

Ansible issue with line file module

I have sample file called clado.txt with following content. [server] [backend] [frontend] I am trying to inset a line 'apache1' under the [server] section. [server] apache1 [backend] [frontend] My playbook --- - hosts: aws become: yes remote_user: ec2-user tasks: - name: editing /home/ec2-user/clad...
Fuji Komalan
1

votes
0

answer
286

Views

Ansible win_shell hangs in git pull

I am using win_shell module to remotely execute a 'git pull' command, But it hangs and no returning values to the terminal. My play book - name: connect to web server 1 hosts: windows gather_facts: false tasks: # - name: execute git pull - win_shell: git pull args: executable: cmd chdir : c:\inetpu...
arshadzackeriya
1

votes
0

answer
285

Views

ansible progess of uri task

After reading the docs it seems that ansible does not support do_until for multiple tasks in blocks and also an include_task. My use case is to do a post on a restful url and then get the status of that restful response and continue doing that. The restful response, for the sake of brevity has two a...
sunny
1

votes
1

answer
1.1k

Views

Get item value in a loop with failed tasks in Ansible

There is a one interesting thing I try to perform with Ansible but something goes wrong. Example: A text file contains IP addresses of some hosts. I need to read each line in the file and check whether SSH port is open for every IP address. If I get a timeout while checking host port then I should k...
Semka Mesilov
1

votes
1

answer
319

Views

v # invalid expression\nsre_constants.error: bad character range , Ansible

I am using Ansible to write a content to a file which looks like : [localhost] localhost [es-master] [es-data] [es-client] The play is : - name: Debug the variable name debug: msg={{ ec2_details | type_debug }} - name: Add Instances to local inventory file local_action: lineinfile path='~/ansible-e...
1

votes
0

answer
26

Views

Custom mechanism to switch to root user using playbook

Till now I had been using become: true for running a task as root user (whenever required). But this time the hardware I am trying to control is a bit different. Its a VM controlled by a different team, where the sudo operations are restricted. You are not allowed to do sudo su either. Simply, sudo...
Insane Coder
0

votes
0

answer
5

Views

Use registered variables in other roles

I want to use a registered variable in another role. In role1 I am checking if the file is empty, when its empty it should output sysfileempty, wififileempty, recopropfileempty and udfpropfileempty. --- - name: Check if sys files Empty command: if [ ! -s filenames/'{{ item }}'files ]; then echo '{{...
Sandro21
1

votes
0

answer
505

Views

ansible - mount -o remount /

A want just remount / on my host. If I use a command module: - name: Change noacl in /etc/fstab become: True replace: dest: /etc/fstab backup: yes regexp: 'noacl' replace: 'acl' register: fstab - name: remounte / become: true command: 'mount -o remount /' when: fstab.changed but I have msg from lint...
Zak Shirak
1

votes
0

answer
304

Views

convert jenkins config.xml to yaml to used in jenkins_job_builder

I am using jenkins-job-builder to generate jenkins jobs. I added ansible plugin to my jenkins, and I want to use that as my deployment tool. When I start converting builder section of my job in yaml it works fine for most of the element. But, I am not able to convert Extra Variables or extraVars and...
Nilesh
1

votes
1

answer
600

Views

Can you change the Interim message by Ansible retries / until module?

In one of my playbooks I start a service and poll for its status before moving onto the next task like the following: - name: Poll for service status uri: url: http://some-service/status register: response until: response.status == 200 retries: 12 delay: 10 This logs a message each time it queries t...
N.L
1

votes
0

answer
217

Views

some uwsgi processes do not reload django application (ansible, nginx, supervisor, uwsgi, django)

Situation: I would like to deploy our Django project's code changes to the stage or production server. For this we have an ansible deployment script, that pulls the django project's code from gitlab, migrates the database, collects the static files, restarts the different servers, etc. Problem: Some...
Mario
1

votes
1

answer
418

Views

ansible playbook: Cannot launch a service as root

I've been banging my head on this one for most of the day, I've tried everything I could without success, even with the help of my sysadmin. (note that I am not at all an ansible expert, I've discovered that today) context: I try to run implement continuous integration of a java service via gitlab....
jlb
1

votes
0

answer
228

Views

How to get unique values in Ansible loop?

I need to get a unique UUID value for each item but instead the values are the same. - debug: msg: '{{item.uuid}}' with_items: - uuid: '{{ lookup('pipe', 'uuidgen') }}' - uuid: '{{ lookup('pipe', 'uuidgen') }}'
dmin
1

votes
1

answer
1.9k

Views

Ansible service task fails with “Could not find the requested service XXX”

I am trying to create ansible playbooks to install and configure kerberos on centos7. I have a task which yum installs the required rpms - name: install kerberos yum: name={{ item }} state=present with_items: - krb5-server - krb5-libs And a task to start the service - name: start kerberos service se...
ayyrex
1

votes
1

answer
146

Views

ansible — don't prompt for variables if the play is skipped

I have an ansible playbook with a few plays, and one play is set up like this: - hosts: windows vars_prompt: - name: 'svnuser' prompt: 'SVN username' private: no - name: 'svnpass' prompt: 'SVN password' tasks: - name: 'Windows Subversion' script: '/root/ansible.password.change/wingen.exp {{svnuser}}...
hymie
1

votes
1

answer
704

Views

Build Docker image using Ansible Playbook (with multi-target Dockerfile)

Is there any option how to implement Docker command (--target parameter) docker build --target backend -t project/backend:latest in Ansible Playbook with docker_image module? Right now in playbook: - hosts: localhost tasks: - name: Build backend image docker_image: path: /var/lib/workspace/project/b...
artificialis_me
1

votes
1

answer
148

Views

ansible: Conditional not working [duplicate]

This question already has an answer here: stdout is not being passed correctly? 1 answer In the following tasks, I am trying to run the second one conditionally but the inequality operator does not seem to work: - name: debug debug: msg: '{{ rv_server_response.stdout }}' - name: setup_ssl -> Instal...
pkaramol
0

votes
1

answer
381

Views

Restrict Ansible script module using sudoers on the remote node

I have a playbook that performs some prechecks on the database as the Oracle user. The remote node is an AIX server and so I created a shell script that is ran via the playbook. --- - hosts: db var_files: - ansible_var.yml tasks: - name: 'DB Checks' become: True become_user: oracle script: '{ db_pre...
kottapar
1

votes
0

answer
121

Views

unable to load ansible playbook to a docker host (host unreachable)

im trying to : ansible-playbook install_docker.yml and keep getting the following error: TASK [setup] ******************************************************************* fatal: [172.17.0.2]: UNREACHABLE! => {'changed': false, 'msg': 'ERROR! SSH encountered an unknown error during the connection. We...
Oz Giat
1

votes
2

answer
191

Views

Tower / AWX job results location in postgresql

I'm trying to get STDOUT/STDERR of a task from Postgresql to use in a commit comment. I have difficulty with finding the right table. Has anyone tried to get a specific task STDOUT/STDERR from Ansible Tower / AWX? Am I barking at the right tree?
MMT
0

votes
0

answer
4

Views

Passing/updating global variables (e.g. group vars) from within the playbook?

I there any way to pass/update group variables from within the playbook task? I need to define variables based on results of some commands from one host to use them for other roles and tasks. I know about set_fact but it stores variable as local variable so that I need to address specific host to ge...
lexadler
1

votes
2

answer
2.1k

Views

local_action copy content file format

I have a playbook output show commands and I'm trying to get it to send the output to a file in human readable format. here is my code: - name: Run a set of commands junos_command: commands: [ 'show route summary', 'show bgp sum' ] output: text provider: '{{ netconf }}' register: showcmds - name: c...
Gary Rubel

View additional questions