Questions tagged [variables]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
56 views

Ansible variable register in two tasks either one or the other

I have an Ansible role that manipulates some Zabbix components. This role has this set of tasks to check the Zabbix Agent type (1 or 2) and version. - name: Check if Zabbix Agent 2 is installed ...
markfree's user avatar
0 votes
0 answers
33 views

Interpolate environmental variable into a string

In a <VirtualHost> block I have this: # Extract the first subdir and assign it to "subdir" SetEnvIfNoCase Request_URI "^/?([^/]*)(?:/|$)" subdir=$1 # Add the subdir to the ...
MonkeyZeus's user avatar
1 vote
1 answer
409 views

bash change directory with spaces and backslash

I'm trying to build a script that I need to be quite able to manage directory with spaces or/and backslashes in their name or not. Inside a bash script or directly on bash shell using variables for ...
SimoneM's user avatar
  • 121
1 vote
1 answer
5k views

Ansible: Loop over template with related variables

Given the variable structure syncjobs: - filename: output1.bash content: data1 - filename: output2.bash content: data2 I want to loop over it creating the files with ansible.builtin....
Andreas Piening's user avatar
0 votes
1 answer
1k views

Pipe into command stored in bash variable

I enter two command in bash: $export g='grep "something"' $echo "something and another thing" | $g But it doesn't work. I want the second command to be evaluated by bash as : ...
rooni's user avatar
  • 139
0 votes
1 answer
770 views

Write original Ansible variable to xml file

I'm trying to find a way to write the original {{ ansible_host }} var in to a xml file. This variable will replace a static IP in a device config. The reason that I want to replace this IP with the ...
Collega's user avatar
  • 65
0 votes
1 answer
4k views

Use variable to construct dictionary key in Ansible

I am trying to update a dict in a hostvar, and the name of the key is constructed using a variable (node). For example, if 'node' is 1 then I want to update hostvars['fakehost']['mydict']['...
TSG's user avatar
  • 1,696
0 votes
0 answers
208 views

Apache2 mod_userdir+mod_authnz_external, how to limit access to own home

I have an Apache2 setup with mod_userdir and mod_authnz_external+pwauth so that each user can access his home and can be authenticated by his local UNIX credentials. Now I need some kind of ...
mstud's user avatar
  • 101
1 vote
1 answer
6k views

Ansible print debug message result variable

I have a simple task that I cannot overcome. I have a playbook that returns AWS EC2 instance configuration. I need to only print (display) private_ip_address. Here my playbook --- - hosts: local ...
housemd's user avatar
  • 15
0 votes
1 answer
1k views

How to permanently set vault token and url remote server in macos

On Linux I'm setting vault variables to /etc/environment next: export VAULT_URL='https://some-remote-server.org:8200/' export VAULT_TOKEN='SoMeToKeN' But when I'm typeing this in macos, after $> ...
soul_assassins's user avatar
-1 votes
2 answers
602 views

SCP exit 0 when using un-initialized variable and fail to copy

I am trying to test if a file fails to transfer using SCP. I noticed if I use a un-initialized variable, I get exit 0 even though the SCP fails. For example, I have an empty variable called ...
coyoteee3's user avatar
1 vote
2 answers
699 views

Bash script - check if a variable is located between 2 others variables?

In a Bash script I want to check if var1 is located between var2 and var3. But I can't find how to do it. Something like this. var1=15 var2=10 var3=20 if [ "$var1" is located beetween "...
Maxime's user avatar
  • 69
0 votes
1 answer
98 views

BASH script variables have no values

I am writing a simple script to clean up log folders. This is the most basic thing I can think of, and yet it does not work because the variables don't seem to be set. Here is the shell script ...
Jay Imerman's user avatar
0 votes
1 answer
84 views

Variables covered in b' ' in Python 3

I am sure this is a fairly noob question, I have googled, and cannot find a straight answer, but I may be asking the wrong thing... I am trying to make an Out Of Box Configuration script, and all the ...
Kevin Rutan's user avatar
0 votes
1 answer
204 views

ansible: difference between a variable and a fact

While I'm using Ansible for quite some time, I'm not sure I really understand the differences between a variable and a fact. Could someone explain me, possibly with an example where it really make a ...
Baptiste Mille-Mathias's user avatar
0 votes
1 answer
145 views

Shell script to remove quotes when using SED

I'm trying to change a line of syntax in a config file where the line looks like the following: host="192.0.2.100" I'm writing a script that would require input the user to change the ip ...
Peter Yates's user avatar
2 votes
2 answers
1k views

How costly are nginx variables?

nginx FAQ Is there a proper way to use nginx variables to make sections of the configuration shorter, using them as macros for making parts of configuration work as templates? ) saying (bold is mine): ...
adrelanos's user avatar
0 votes
1 answer
3k views

Get the previous day date as variable in batch file from powershell command output

The scenario is like this. I need a previous day date (i.e. Today -1) as variable in a batch file. But if previous day is Sunday (i.e. script running on Monday) it should return the Saturday's date (i....
Niraj Jaradi's user avatar
1 vote
1 answer
753 views

How does systemctl variable escaping work in a shell?

I want do a batch job with systemctl, something like: systemctl status v2ray-haproxy@{1..5} That's fine. But when i change 5 to a variable: n=5;systemctl status v2ray-haproxy@{1..$n} It's not ...
Rampage's user avatar
  • 11
0 votes
2 answers
860 views

ssh : user and host / host_ip as variables

I would like to create an array with the variables $user and $host in order to pass them to the ssh command. I have tried: my_array=('something1' 'something2' 'user' 'host_ip') sudo ssh ${my_array[2]...
Phineas's user avatar
  • 103
2 votes
3 answers
7k views

Kickstart CentOS 7 with pre-defined static IP and hostname (%pre) and used in KS, possible?

I don't know if this is possible, but going to ask anyways. I am trying to Kickstart newer servers of us with CentOS 7. So far I got most working, however for some reason if I use variables in the %...
HudsonHawk's user avatar
2 votes
1 answer
2k views

ANSIBLE how to locate dict at host_vars file?

I try to master the work with dictionaries at ansible. When I include dict to playbook as at example all works like charm. But when I try to include vars block to my host_vars/myserv.yml file like ...
Kein's user avatar
  • 131
0 votes
1 answer
2k views

Ansible - manage installed apps and send output via email - variables are filling wrong

so i have this playbook, which checking, if there are installed selected packages. nothing special there. Then i would like to send an output to my email, if everything went right etc. --- - name: ...
helloweenx's user avatar
0 votes
0 answers
591 views

How can I add multiple variables in Ansible PB from another file

I plan to add few hundred of lines in some files using Ansible. My idea is to put all those lines in a file and then use a variable inside the playbook. This is the first part. The second one is ...
razvanli's user avatar
4 votes
1 answer
17k views

Get PowerShell command output as a variable in bat (cmd) script

I'm trying to get FQDN of a host in some .cmd file. We have disjointed AD domain so "@echo %COMPUTERNAME%.%USERDNSDOMAIN%" does not work. I mean it works, but returns wrong value. The solution I ...
Papa Smurf's user avatar
984 votes
15 answers
1.4m views

How to determine if a bash variable is empty?

What is the best way to determine if a variable in bash is empty ("")? I have heard that it is recommended that I do if [ "x$variable" = "x" ] Is that the correct way? (there must be something more ...
Brent 's user avatar
  • 22.9k