Questions tagged [ansible-playbook]

468 questions
-1
votes
1 answer

Use role vars in Ansible Jinja2 template loop

I have a dictionary of vars in an Ansible role ( in roles/my_role/vars/main.yml ): my_vars: - name: var1 string: var1_string - name: var1 string: var1_string I want to include all of these in a single file constructed with a jinja2…
Garreth McDaid
  • 3,449
  • 1
  • 27
  • 42
-1
votes
2 answers

how can i terminate ec2 instances using ansible dynamic inventory?

i have searched the whole internet and cannot find anwser to this question. "how can i terminate an ec2 instance using dynamic inventory with tags?" so if i can terminate an instance or group of ec2 instances with specific tag(s) the ec2 module…
uberrebu
  • 503
  • 6
  • 17
  • 36
-1
votes
1 answer

ansible: sum over fact array

I want to get disk sizes of multiple disks and sum them to check if the sum of their sizes is greater than the minimum required. We are going to use LVM to create mountpoints, we need to be able to use singe disk or multiple disks. I'm able to get…
vijay rajah
  • 161
  • 2
  • 9
-1
votes
3 answers

How to manage hosts with multiple sites using Ansible?

I have this sample inventory file: [web1] // Web Server 1 contains the following sites: example1.com example2.com [web2] // Web Server 2 contains the following sites: example3.com example4.com But whenever I run a playbook for example with apt-get…
JohnnyQ
  • 117
  • 2
  • 8
-1
votes
2 answers

Override hosts variable of Ansible playbook without command line

Have 2 hosts my_host1, my_host2 This code work for my_host1, I also need run it for my_host2 Can be overridden hosts value on ansible main.yml task without changing string "hosts: my_host1" in init playbook.yml? Command line --extra-vars is not the…
-1
votes
1 answer

issue with playbook script

How can I write a playbook to Make sure both NFS server and client listen to same domain in /etc/idmapd.conf and confirmed with nfsidmap -d [General] Verbosity = 0 Pipefs-Directory = /run/rpc_pipefs # set your own domain here, if it differs from…
sameer
  • 19
  • 3
-1
votes
1 answer

ansbile template weird formatting

I'm trying to create yaml based configuration files. Everything is working except that the lines after a loop is being indented for some reason. So when I have this... - job_name: {{ inventory_hostname }} pipeline_stages: - regex: …
flyerhawk
  • 27
  • 3
-1
votes
1 answer

Ansible: Simple comparison failing when comparing integers

I have the following: - set_fact: test_string: "{{ htmlres.content | regex_search('test-([0-9]+)', '\\1') | first}}" This retrieves 2 which is part of a string contained in the htmlres.content content which is test-2. So now I'm trying to…
Ress
  • 45
  • 1
  • 2
  • 8
-1
votes
1 answer

Ansible: populate new fields in each item of a list

I'm a total Ansible and Python beginner. I have a list: my_items: - name: item1 unix_user: unixuser1 homedir: /home/unixuser2 - name: item2 unix_user: unixuser2 homedir: /home/unixuser2 I would like to create a pureftpd virtual user for…
-1
votes
1 answer

Adding arguments to Packer's Ansible provisioner

My Friday brain is really struggling to convert an Ansible command line into the format my Packer .json wants. The Ansible: ansible-playbook playbook.yml -e @env/users/user01.yml --ask-vault --ask-become My attempted Packer block: "provisioners":…
Sam
  • 183
  • 1
  • 5
-2
votes
3 answers

Forcing ansible to print on console exatly what I want

I have several tasks to do with ansible ( because it is great environment). However I want to achieve two things: have on stdout only exactly what I want ( I mean only this output which I place in msg variable, and NOTHING ELSE) I would like to be…
kakaz
  • 167
  • 8
-2
votes
1 answer

How to copy a 1 GB file using ansible to remote machine as different remote user and password

I have tried to copy a file output of the ansible-playbook looks ok , but the file was copied to local machine not to remote machine in the location dest mentioned in yaml file. bash-4.2# ansible --version ansible 2.6.3 config file =…
-2
votes
2 answers

Error while connecting to remote host using Ansible

Geting error while connecting to remote Mysql host using Ansible. Playbook as below --- - name: "Create database" login_host: host.xyz.com login_password: "{{ mysql_root_pass }}" login_port: "{{ mysql_port }}" login_user: "{{ mysql_root…
sanjayparmar
  • 633
  • 8
  • 19
-2
votes
1 answer

unable to ssh from ansible to remote host

Iam trying to run a playbook of ansible on the remote host. But the first step of logging in isnt happening. tried the following: updated the ansible/hosts file with the remote host credentials Adding host_key_checking=false In sshd_config file I…
Amruthapv
  • 1
  • 1
  • 1
-2
votes
3 answers

No package matching 'vim' on Centos7 (via EPEL) using ansible

Installing vim8 epel role task: --- - name: Install epel-release yum: name=epel-release state=latest become: yes vim role task: --- - name: Install vim yum: disablerepo=* enablerepo=epel update_cache=yes name=vim state=latest become:…
anon
1 2 3
31
32