Questions tagged [ansible]

1

votes
1

answer
1.2k

Views

Ansible - Change SSH user during playbook execution

I'm new to ansible, maybe someone can help me with this configuration. I have an inventory of multiple servers. SSH access to these servers is secured using PEM key files. I have a playbook and want to change the ansible ssh user (default devops) to root if user devops on the remote host not exists....
thomas tugend
1

votes
1

answer
707

Views

Run python scripts multiple times through Ansible playbook with command line arguments

I am trying to run a Python script multiple times through my Ansible playbook using with_items to take different command line arguments with each iteration, but even though, it iterates through the loop to take different names for the generated files, but the contents of the files remain the same: i...
Aastha Maingi
1

votes
1

answer
501

Views

How can I escape single quotes for Ansible/Jinja2 ternary operator?

I have the snippet below. Basically, for an included task I would like to provide a variable whose contents look like the below string: --date='something' or it should be empty if the original variable is an empty string. The thing is, I need the string to be in the form above, including the single...
Andrei Dascalu
1

votes
1

answer
53

Views

Ansible ec2_eni module. How to add additional security_groups for an ec2_eni interface?

I am trying add additional security_groups to my existing ec2_ENIs. The module ec2_eni seems like non idempotent. When I add a new security group using ec2_eni module it removes the existing groups and adds only the group I have mentioned in the playbook. So the option left for me is to get the exis...
partha sarathi
1

votes
1

answer
209

Views

Mixed strategy in ansible playbook

Is it possible to run a set of Ansible tasks with free strategy (all tasks running at the same time). And once they all are done, run another set from within the same playbook? Importing second playbook could work, but even so, I'm not quite sure how Ansible will handle free strategy execution and p...
JoeRivz
1

votes
1

answer
293

Views

Prompts in Jenkins

I am trying to install software on centos 7 using ansible playbook through jenkins. I am trying to call ansible playbook from jenkins for installing the software. I am using vars_prompt in ansible playbook to pass some user-defined parameters, when i run the ansible playbook manually, it asks for pr...
004
1

votes
1

answer
627

Views

Ansible AWX RabbitMQ container in Kubernetes Failed to get nodes from k8s with nxdomain

I am trying to get Ansible AWX installed on my Kubernetes cluster but the RabbitMQ container is throwing 'Failed to get nodes from k8s' error. Below are the version of platforms I am using [node1 ~]# kubectl version Client Version: version.Info{Major:'1', Minor:'9', GitVersion:'v1.9.5', GitCommit:...
kaylor
1

votes
1

answer
847

Views

How to call Azure CLI functions from Ansible

I am trying to create an Ansible playbook for the bot framework. From the looks of it the REST API cant be used to create the bots but it is available from the Azure CLI https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-tools-az-cli?view=azure-bot-service-3.0 . Is there a way to call A...
rustyocean
1

votes
1

answer
48

Views

How to access register variable in task

This is my output of EC2 instance. I am trying to access 'instance_type'. And here is my task. ec2: key_name: redhat group: MY_EC2 instance_type: t2.micro image: ami-cfe4b2b0 region: us-east-1 zone: us-east-1a wait: true exact_count: 1 count_tag: name: MyProjectInstances instance_tags: name: Ansible...
gaurav bhatt
1

votes
0

answer
68

Views

npm packages globally - any solution for use 1 install for ALL projects?

Is any solution to use npm with all projects wthout running always npm link? I use VCCW ~/.npmrc prefix = ${HOME}/.npm-packages npm instal # Install npm packages - name: Place a ~/.npmrc become: yes template: src: templates/.npmrc dest: '{{ ansible_env.HOME }}/.npmrc' - name: Install npm packages be...
user7943875
1

votes
0

answer
366

Views

Cannot restore and dump database PostgreSQL with Ansible

The part of code that gives me an error is: - name: import database jira64_20180626.dump.tar.gz postgresql_db: name: jira64_20180626.dump.gz login_user: jira login_password: jira_pwd state: restore target: /var/lib/pgsql/jira64_20180626.dump.tar.gz The error is: fatal: [node-1]: FAILED! => {'change...
Aless1995
1

votes
1

answer
420

Views

jinja2 Ansible filter dictionary

I've been doing ansible for a while, but have recently started doing some more advanced things such as pulling data to drive actions from outside sources. This has resulted in me having to dig a little deeper into how ansible allows logic and parsing of variables, requiring me to dig a little into...
Scott Bowe
1

votes
0

answer
112

Views

execute ansible loop according to count value.count=3 should take only 3 values rest it shouldnot execute

I want to execute an ansible playbook according to the count value passed. If I pass a count value of 3 then the loop should take only 3 values present in the loop. Below is my playbook: --- - name: Decommission Tenant virtual machine hosts: localhost gather_facts: false vars: VMType: '{{VMType}}' v...
cena
1

votes
1

answer
335

Views

Ansible. Uninstall Windows Program

I'm trying to remove the program in Windows 10 via Ansible. The connection is configured, the client is available and pings. The task passes without errors, but nothing happens, the program is still in place. I assume that the problem lies in the access rights, although I have already created the ri...
user3792982
1

votes
0

answer
92

Views

Is Ansible Tower compatible with the aws_S3 module?

I have been trying to automate a backup of some server files from a target machine to our S3 instance, but when I run the playbook from Ansible Tower it doesn't seem that the S3 module is able to see any files on the target machine. AWS authentication is set up with IAM and working properly (authen...
blockchainwtf
1

votes
1

answer
103

Views

Locate string/integer not in list

Im pulling a list of VLANs from our IPAM via an API and I want to be able to locate an unused 'vlanId' that isnt in the list. I was expecting that I could use with_items for the JSON content and then use the random function with an until loop and occasionally it will initially generate a number tha...
Kyle Quilliam
1

votes
1

answer
1.5k

Views

Ansible “Failed to connect to host via ssh: Permission denied” when trying -m ping all

I've been at this all morning, and I've seen multiple posts about this error in other places, but none of the solutions seem to be working for me at this point. I'm playing around with Ansible and trying to setup my inventory + hosts for this project. For my hosts file I have (/etc/ansible/hosts):...
Adyn Glowniak
1

votes
1

answer
297

Views

“No module named 'exceptions” error when running Ansible on Ubuntu in WSL and doing an Ansible ping with a host

Does anybody know a solution to fix the below error? I suspect this is because Ansible is using Python3 and the module errors does not exist in this version xx.xx.xx.xx | FAILED! => { 'changed': false, 'failed': true, 'invocation': { 'module_name': 'ping' }, 'module_stderr': '', 'module_stdout': 'Tr...
MiniMe
1

votes
1

answer
33

Views

Ansible Extract JSON Tag

I'm trying to work with Infoblox API, and it's responses. I would need to extract values of tags from the response, that seems to be in JSON format, but I cannot find the way to do it. Here is my playbook: - name: 'Checking _node_exporter Service Record for {{ inventory_hostname }}' local_action: mo...
Tamás Juhász
1

votes
1

answer
112

Views

Openstack Get the newly created port ID using Ansible

I have currently created one nic port using os_port module and now I am trying to get the ID of the newly created port and use it in the next tasks in Ansible. - os_port: state: present fixed_ips: - ip_address: 172.30.137.138 allowed_address_pairs: - ip_address: 172.30.137.128/27 name: port-3 secur...
Romain
1

votes
0

answer
101

Views

Using Ansible Playbook Bundles with multiline secrets on Openshift

While using Ansible Playbook Bundles secrets are specified as in https://github.com/openshift/ansible-service-broker/blob/master/docs/secrets.md However, multiline secrets do not seem to work as usual. If secrets are added through create_broker_secret.py, a multiline secret will change its newlines...
djuarez
1

votes
1

answer
49

Views

How to get specified values from ansbile facts

I'm confused a little bit. I alredy tried jmespath, but didn't help. I need to get a high-level object which contains a specified object. In the example below we see an ansible fact about HDDs. I need to get the disk name (sdf, sdg or dm-0) of the HDD which contains a specified partition, e.g. sdf1....
1

votes
1

answer
54

Views

Can I have multiple parameter values in ansible module?

Is it possible to have multiple parameters values in ansible e.g., state=present, mounted? - name: create partition parted: device=/dev/sdc number=1 state=present - name: Create a ext4 filesystem on /dev/sdc1 and check disk blocks filesystem: fstype=ext4 dev=/dev/sdc1 - name: mount the directory mou...
Negi Anurag
1

votes
0

answer
322

Views

Is it possible to modify GNOME desktop file metadata from non-GUI session using gio?

Running CentOS 7 with GNOME 3.22.2, and I am trying to write an Ansible playbook to copy icons from /usr/share/applications to a pre-defined user's desktop and then grant trusted permission (Using gio set 'metadata::trusted' yes). When I try to see the writeable attributes of the desktop icon from a...
jhrabi
1

votes
1

answer
1k

Views

Using Ansible to stop service that might not exist

I am using Ansible 2.6.1. I am trying to ensure that certain service is not running on target hosts. Problem is that the service might not exist at all on some hosts. If this is the case Ansible fails with error because of missing service. Services are run by Systemd. Using service module: - name: S...
Madoc Comadrin
1

votes
1

answer
351

Views

ansible vmware windows server

I am trying to execute my ansible playbook to launch VMware-windows-server with IP settings, but VM is getting launched but without IP settings. after executing the playbook am not getting any errors and its shows changes also done, but when i checked in Vmware environment IP is not reflecting. trie...
naveen
1

votes
2

answer
720

Views

How to send email as a condition in Ansible Playbook?

I have created a playbook on Ansible to Yum Update on every Linux Server I have. I have incorporated the mail module to send an email for every host after the playbook has been completed, even if the server was not updated. I was wondering if it is possible to only send an email to me IF the server...
Riyad Ali
1

votes
0

answer
34

Views

ec2_ami_copy - Unhandled exception - error(104, 'Connection reset by peer')

I'm trying to encrypt an AWS AMI, but getting the below error. fatal: [localhost]: FAILED! => { 'changed': false, 'failed': true, 'invocation': { 'module_args': { 'aws_access_key': 'xxxxxxxxxxxxxx', 'aws_secret_key': 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER', 'description': '', 'ec2_url': null, 'encrypt...
makawana
1

votes
0

answer
49

Views

Ansible RBAC module

I would need to translate the following Openstack command in an Ansible task: neutron rbac-create --target-tenant --action access_as_shared --type network Is any module that helps creating the RBAC in Ansible?
Albert
1

votes
1

answer
53

Views

Why is include_role processing one host at a time?

I've created an auxiliary role to build software packages from source. However, when I try to include it in a loop -- looping over a dictionary describing the packages. It works, but, when I include it from another role's task: - name: Build packages include_role: name: native-package loop: '{{ srcp...
Mikhail T.
1

votes
0

answer
61

Views

update/modify nested dict values inside a list

I have a variable which is a list of dictionaries with a nested dictionary, like the following: my_users: - { name: 'James Doe', user_id: 'xman01', user_password: { clear_text: 'password1', hash_md5: '', hash_sha512: '' } } - { name: 'John Dean', user_id: 'xman02', user_password: { clear_text: 'pass...
acavagni
1

votes
1

answer
44

Views

Setting up correctly gateway_ip in Ansible function

I am using the following function to deploy an Openstack subnet using Ansible and variable file: - name: Create the subnets os_subnet: cloud: '{{ item.cloud }}' state: present validate_certs: no gateway_ip: '{{ item.gateway_ip | default(None) }}' dns_nameservers: '{{ item.dns if item.dns is defi...
Albert
1

votes
0

answer
44

Views

Rerun on failed hosts only from workflow and inventory [duplicate]

This question already has an answer here: “When” condition on Ansible playbook doesn't work as expected using operators 1 answer Finding a string within an stdout_lines array 1 answer I have written a playbook to do a service check, for this example lets say to check if port 110 and 143 is lis...
Julian Kriel
1

votes
1

answer
159

Views

How to exclude instances of the EC2 inventory in Ansible?

We have an Ansible server using EC2 dynamic inventory: https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.py https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.ini However, with the number of instances we have, running ./ec2.py --list or ./ec2.py --refresh-cache ret...
chacd
1

votes
1

answer
395

Views

Apache Graceful restart with Ansible

What is ideal ansible way to do a apache graceful restart? - name: Restart Apache gracefully command: apachectl -k graceful Ansible systemd module does the same? If not, what is the difference? Thanks ! - name: Restart apache service. systemd: name: apache2 daemon_reload: yes state: restarted
Arky
1

votes
1

answer
161

Views

How to iterate across Ansible inventory whilst referencing hostvars in add_host

I want to dynamically create an in-memory inventory which is a filter of a standard inventory including only the host where a specific service is installed. The filtered inventory is to be used in a subsequent play. So I identify the IP address of the host where the service is installed. - name: fi...
skinnygav
1

votes
1

answer
646

Views

Upgrading from AWX 1.0.6 to 1.0.7

How does everyone feel about awx 1.0.7? And the upgrade process? I tried to upgrade from 106 to 107 and then move my data between a 106 machine and the new 107 server. I did this with tower-cli. I found that tower-cli 3.2.1 works with awx 106, but not with 107. Yet, tower-cli 3.3.x works with awx 10...
awx_user
0

votes
1

answer
82

Views

Ansible loop related issues

I have a playbook which has multiple roles and serial setup so that fist it's running on one machine then on the rest of them. In one of the roles I have the following tasks: - name: getting dbnodes IP addresses local_action: shell echo '{% for host in groups['dbnodes'] %}{{ hostvars[host]['ansible...
zozo6015
1

votes
0

answer
40

Views

Ansible - password containing one double quote is not parsed correctly

The password of one of my servers contains a double quote, e.g. dga'fddf. I've tried both assignments below in inventory.ini file ansible_ssh_pass=dga\'fddf ansible_ssh_pass='dga'fddf' and I have debug msg in my playbook debug: msg: 'ansible_ssh_pass: {{ ansible_ssh_pass }}' the result from both ass...
Joy zhou
1

votes
0

answer
178

Views

Ansible install and run flask server [duplicate]

This question already has an answer here: Daemonizing an executable in ansible 5 answers ansible run command on remote host in background 1 answer I want to use Ansible to configure my project on localhost. The idea behind it is to give user the ansible playbook, and once the user directly runs th...
Siddharth Pathak

View additional questions