Questions tagged [ansible]

1

votes
1

answer
1.2k

Views

how to control the execution of rescue module in ansible

I have a playbook like this below ,i want to control execution of rescue when the block goes wrong。 I add when: is_debug is defined after rescue ,but when i run ansible-playbook dashboard.yml ,not give the is_debug value, the rescue is still excute when block has error . i want know how to cont...
qianwang
1

votes
2

answer
655

Views

CentOS 5. ansible_python_interpreter=/usr/bin/python26. Still cannot use yum: module

Still have to keep some CentOS5 hosts, they have yum configured to use CentOS vault repo like this https://hastebin.com/ojopevanas.ini. That works fine when use yum there on host. When however I try to use ansible for that, like: - name: "Install OS packages" yum: pkg={{item}} state=installed with_i...
Tag Wint
1

votes
0

answer
5

Views

Parsing XML with Namespace using Ansible, specifically a JBOSS standalone.xml

I am attempting to change values in a standalone-full.xml configuration file for a JBoss server. The issue I am running into is with the namespace. I have done several searches and tried several different scenarios, which I will provide. I know this has something to do with the namespace, because wh...
John
1

votes
1

answer
22

Views

How to check if dictionary key is null

I have json variable: "variable": { "changed": false, "data": null, "failed": false, "index": "135" } How to test if variable.data is null? I tried these, none works: when: variable.data is null when: variable.data is None when: variable.data is NoneType when: variable.data == 'None' when: variable....
BartBiczBoży
0

votes
0

answer
4

Views

ansible - create webhook for bitbucket repos

I want to write an ansible playbook using bit bucket rest api, which creates a webhook to trigger a jenkins pipeline with every merge. This is what I wrote: - name: create webhook for pipeline trigger uri: url: "{{ repo.location }}/webhooks" method: POST user: "{{username}}" password: "{{password}}"...
IrinaS
0

votes
0

answer
4

Views

Ansible — Using Conditionals from Ec2 Tags in Dynamic Inventory

I am using ec2 dynamic inventory. All of my ec2 instances are tagged with their environment. So for example tag:env = prod or tag:env = test So my dynamic inventory has variables set properly.... "ec2": [ "ip_10_1_1_1_ec2_internal", "ip_10_1_1_2_ec2_internal", "ip_10_1_1_3_ec2_internal", "ip_10_1_...
emmdee
0

votes
0

answer
3

Views

Adding a Ansible variable to Cassandra config template Yaml

I'm using Ansible to setup an AWS Cassandra cluster and I'm trying to pass the dynamic IPs to a YML template file. I have the IPs assigned to an Ansible group variable and want to use this when populating my Cassandra config YML. In Play 1 I initially assign the group like: file : roles/gather_cas...
MeanwhileInHell
1

votes
1

answer
9

Views

How can I use the mv module Ansible

I am trying to use the mv module on Ansible but I am not having luck. In my initial attempt I did the following: - name: changing the name of the file shell: mv /tmp/bundle /opt/Rocket.Chat And I get the following error: FAILED! => {"changed": true, "cmd": "mv /tmp/bundle /opt/Rocket.Chat", "delta":...
Marco Alfaro
1

votes
2

answer
2.8k

Views

“pause” for every host

Before rolling updates I want to set downtime for every host in our monitoring tool. I created a custom module for this. There might be problems when setting downtime which can not be fixed on our end. In that case I want to give the user the choice to decide if the deployment should be aborted or c...
udondan
1

votes
1

answer
4.8k

Views

Ansible: make output from a command become a key-value item/variable for the next command

I want to use this output (from a previous command) as an array of key-values or as an inventory for the next command in the same playbook stdout: hot-01: 10.100.0.101 hot-02: 10.100.0.102 hot-03: 10.100.0.103 .... hot-32: 10.100.0.132 like this: - shell: "echo {{ item.key }} has value {{ item.value...
ady8531
1

votes
1

answer
1.7k

Views

How to use nested variables (dictionary keys) in Ansible?

Feel free to suggest or directly edit my question if it's not expressed clearly. I have some nested variables declared in Ansible like this: # vars/main.yml parent_key: child_key1: "child_value1" child_key2: "Resolving: {{ child_key1 }}" But Ansible says: child_key1 not defined or something similar....
Neil
1

votes
2

answer
1.2k

Views

ansible playbook public keys issue

I've got this basic playbook that appends all the public keys located in the public_keys folder to the user's folder in .ssh/authorized_keys: - hosts: default vars: user: user1 tasks: - name: Set up authorized_keys for the user authorized_key: user={{ user }} key="{{ item }}" with_fileglob: - public...
miticoluis
1

votes
2

answer
5.1k

Views

[WARNING]: provided hosts list is empty, only localhost is available when inventory exists

I'm trying to get a list of facts available about my azure VM by running ansible -m setup hostname as described in the FAQ So I have ansible -m setup my-vm1 which I run from the machine in the azure cloud that I normally run my ansible commnads from (the machine I normally successfully use to talk t...
andrea
1

votes
1

answer
2.2k

Views

Aws passing credentials to ansible s3 module

In ansible,When I am passing the access key,secret key,token to my aws credentials,it passes the access key to my ansible module s3 ,but when I am passing secret key and token it shows me ""VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" like that.So how can I solve this. In accesskey id there is no extra spe...
jake
1

votes
1

answer
2.3k

Views

Ansible mysql grant

I want to grant privilege on a db(test_db) to a user(test_user) using Ansible. My command is as shown below. grant all PRIVILEGES on .* to @'localhost'; How will I execute the command using Ansible.
Pattu
1

votes
2

answer
3.4k

Views

Ansible & Jinja2: combine a dictionary to each element of a list

I have a variable that is an array [{'foo':1},{'bar':2}]. I want to combine it with the following hash: {'baz':3} using a set fact (?) such as my output registered variable is: [{'foo':1, 'baz':3},{'bar':2, 'baz':3}] I've looked into the combine filter, but it only works when I already have an hash...
Stephane
1

votes
0

answer
5

Views

Ansible: Extract value from json array

I've run this command to get all the Internet Gateways in my AWS account with the tag value prefix of 'myVar_igw_'. My aim is to extract the tag value from the output. - name: IGW Facts ec2_vpc_igw_facts: region: "eu-west-2" filters: tag:myVar: "myVar_igw_*" register: igw_facts Outputting the igw_fa...
Danzaa
1

votes
2

answer
941

Views

Ansible update still shows old version

I upgraded ansible from version 2.0 to 2.3.1 on a Debian 8 server and followed the instructions that Ansible provided: Add to Sources list: deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main Run Following Commands: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7B...
ryekayo
1

votes
1

answer
2.4k

Views

Ansible logging

I am having difficulty getting Ansible to perform logging. A simple YAML named demo5.yml spins up AWS EC2 instances (below). The following entry has been added into the ansible.cfg file: log_pth=/var/log/ansible.log The playbook YAML is executed by calling: ansible-playbook demo5.yml -v There is not...
Backwardation25
1

votes
1

answer
741

Views

Execute background process from Ansible

Ansible runs processing using SSH. Therefore, it is not possible to start the background process. Is there a solution to start background processes with Ansible? Thank you.
Kun Ns
1

votes
0

answer
61

Views

Possible to test dynamic ansible variables with testinfra/pytest

I am using testinfra/pytest to test my ansible variables with: vars.yml FRUIT: "apple" IS_APPLE: '{{ FRUIT == "apple"}}' test.py import pytest @pytest.fixture() def AnsibleVars(host): ansible_vars = host.ansible("include_vars", "file=vars.yml") return ansible_vars["ansible_facts"] def test_vars(Ansi...
u123
0

votes
0

answer
4

Views

Trying to build playbook for install airflow (On virtualenv folder). Ansible not executing commands inside the virtualenv environment

Trying to build playbook which can install apache-ariflow on virtualenv environment. Ansible not executing commands inside the virtualenv folder. Below is the my playbook and error. Playbook Content :- - name: Active virtual Environment shell: source bin/activate args: chdir: "{{ directory }}" - nam...
Balaji Mungal
1

votes
1

answer
85

Views

Update Password if user exist Ansible

Im new on Ansible and i try to create some user accounts on remote servers and i encountered some trouble. I want to create users if they do not exist, and update them password if they are present. I read the documentation and found the parameter "update_password" but im stuck on how to verify thei...
HastEd
1

votes
2

answer
54

Views

Parsing value from non-trivial JSON using Ansibles uri module

I have this (in the example shown I reduced it by removing many lines) non-trivial JSON retrieved from a Spark server: { "spark.worker.cleanup.enabled": true, "spark.worker.ui.retainedDrivers": 50, "spark.worker.cleanup.appDataTtl": 7200, "fusion.spark.worker.webui.port": 8082, "fusion.spark.worker....
Marged
1

votes
2

answer
41

Views

clone Git Repository

I wrote an ansible playbook which creates a new BitBucket repository. Now I want to configure the repository according to the instructions shown under the repository source in BitBucket: You have an empty repository To get started you will need to run these commands in your terminal. New to Git? Lea...
IrinaS
1

votes
2

answer
43

Views

If else in ansible print statement

I would like some help with syntax for a print statment that has multiple conditions. Currently, the quotes for '{{inventory_hostname}}' is causing errors and if I remove the quotes the playbook runs but lists the text inventory_hostname instead of the variable. I would like know how I can get the v...
techkid
1

votes
1

answer
12

Views

Ansible linefile module's attribute line is not adding environmental variable on server

Hi I am having a task which is as follows - name: Replace log directory in configuration lineinfile: path: $HOME/amsible_test/test.txt regexp: '^dataDir=' line: 'dataDir=$HOME/.zookeeper_log' it's running fine , But issue is that this is writing line as dataDir=$HOME/.zookeeper_log but as per my...
Pankaj Cheema
0

votes
2

answer
21

Views

Is ansible compatible with Ubuntu 18.04? [on hold]

I am trying to run small playbook over Ubuntu 18.04 virtual machine and facing the issue while it gathers the facts. PLAY [all] ****************************************************************************************************************************************************************************...
srinivas ga
0

votes
0

answer
3

Views

In an Ansible playbook, what is a better way to iterate over a list of objects and call a different role depending on that object's data?

I am using Ansible to read in a YAML file containing a list of dictionaries. I then need to iterate through this list and call a different role depending on data within each list object. I have a solution that is working, but it seems so kludgy to me, that I wanted to find out if there was a better...
Kris
1

votes
2

answer
1.5k

Views

how can i pass the parameter as “integer” in ansible?

so i have this piece of yaml in my ansible project. - name: common | register vim as a type of editor for update-alternatives command: update-alternatives --install "/usr/bin/editor" "editor" $(which vim) 100 sudo: yes What I want to do is to register as a kind of editor, set the priority to 100. as...
Ya Zhuang
1

votes
1

answer
3.3k

Views

How should script output be formatted for Ansible reporting?

I'm using Ansible v1.3 to run a bash script on a group of servers. I'm trying to get my output to work with what Ansible is expecting to format the output correctly but I'm missing something. I've read somewhere (can't find the link!) that if script output is formatted as JSON, Ansible will pick it...
Michael J
0

votes
0

answer
6

Views

How to install Docker in AWS EC2 with Ansible?

I'm new to Ansible, and I'm about to install Docker in my existing EC2 with Ansible. Here is full Ansible scenario is Docker will be installed in my EC2 instance first, if Docker is not available Docker images will be pulled by Ansible from [somewhere] Run that docker images in Ec2 with Ansible. An...
Pyae Phyoe Shein
1

votes
2

answer
1.9k

Views

Can I install (or remove) Ansible role from Galaxy using ansible-pull?

I'm working with Ansible using ansible-pull (runs on cron). Can I install Ansible role from Ansible Galaxy without login in to all computers (just by adding a command to my Ansible playbook)?
Pavel Bernshtam
1

votes
1

answer
336

Views

File not created in ansible

I have installed ansible on one machine and trying to execute commands on another (remote) machinge. Ansible successfully installed Able to reach all hosts (local and remote). Tested with ansible all -m ping This was successful Trying to execute a simple command again ansible all -a 'echo "hello...
Vasu
1

votes
1

answer
343

Views

Simplifying ansible file checks?

In ansible I'm doing a lot of this: - name: Check if [someFile] exists on host stat: path=[someFile] register: someFile - fail: msg="[someFile] not found" when: someFile.stat.exists == False I'd like to be able to express it more succinctly. Something like this: - fail_on_missing_file: path: [someF...
Chris Beach
1

votes
1

answer
651

Views

ansible nginx server_name values

I've got the following ansible hosts file: [production] 255.255.255.1 255.255.255.2 255.255.255.3 My inventory file has an nginx role that has a config template file that gets copied to the nginx directory on the servers during the setup deploy. At the moment part of this config file looks like this...
railsuser400
1

votes
1

answer
3.1k

Views

Skip an item in an Ansible task loop

Let's say I have a group var named show_canada which is a boolean. I have the following task: - name: install conf file template: src="example.conf.j2" dest="/etc/{{ item }}/example.conf" sudo: yes with_items: - usa - brazil - canada - japan - turkey How can I have the task skip the canada item depe...
user1087973
1

votes
2

answer
590

Views

How to structure ansible roles for multiple application use?

I'm looking for the most modular way to use ansible to provision a server that will host multiple node.js applications on it. The current setup I have is not scalable. The roles I have are common, nginx, nodejs, mongodb, apps. The apps hash/dictionary I maintain a dict called apps in roles/apps/defa...
izolate
1

votes
1

answer
3.5k

Views

Ansible error change handler is not defined

I'm trying to run my first playbook to install Java on four servers and subsequently define a JAVA_HOME environment variable. ansible-playbook site.yml --check PLAY [crave_servers] ********************************************************** GATHERING FACTS ********************************************...
alex sundukovskiy
1

votes
2

answer
1.1k

Views

Why does Ansible fail to execute this simple shell script?

I came across a very strange problem with Ansible (1.8.2) that boils down to executing this simple command in a shell script: #!/bin/sh # transform a String into lowercase chars: echo "TeSt" | tr [:upper:] [:lower:] When I log into the remote Solaris machine, this script seems to work no matter in w...
dokaspar

View additional questions

Смотреть фильмы онлайн бабушка легкого поведения 2 фильм бесплатно