Questions tagged [variables]
30 questions
0
votes
0 answers
Is it possible to populate list of values in ansible's defaults/main.yml?
Having a custom inventory data structures and input arguments of a role, I want to populate those input arguments from inventory data structures. Is it possible to somehow populate list in a loop? For example, this is inventory structure: ---…
0
votes
1 answer
sh Script Syntax Assistance
I'm trying to write a script that will read search strings from an input file and then execute a command with $string in the middle of the command line. This is an example of the working command line: postqueue -p | tail -n +2 | awk 'BEGIN { RS = ""…
Drew
- 101
0
votes
1 answer
Ansible global group_vars/all.yml taking precedence over inventory group_vars/all.yml
In Ansible 2.16.8 on a Mac (M1) running Python 3.12.4 (via homebrew) I am trying to setup a global group_vars/all.yml that can be overwritten by inventory/x/group_vars/all.yml if needed. However, it seems that the global file is overwriting the…
Panduar
- 3
- 3
0
votes
0 answers
Ansible variable precedence in a play vs in a task
I'm struggling a bit with variables precedences in my play and in a task. I'm using this play, which works great but I've add a last task to reboot my windows server BUT i have to use a special account (so a new ansible_user and ansible_password ).…
motorbass
- 453
0
votes
0 answers
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 logging path CustomLog "|bin/rotatelogs.exe -l…
MonkeyZeus
- 300
0
votes
1 answer
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 : echo "something and another thing" | grep "something" What should I do for…
rooni
- 149
0
votes
1 answer
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 original variable in the file, is because later in…
Collega
- 75
0
votes
1 answer
Apache2 mod_userdir and mod_authnz_external, how to limit access to own home
Apache2 setup with mod_userdir and mod_authnz_external and pwauth , so that each user can access their home and can be authenticated by their local UNIX credentials. Now I need some kind of authorization so that each user can, after being…
mstud
- 101
0
votes
1 answer
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 $> vault status I'm getting Error checking seal status:…
0
votes
1 answer
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 beginning, where it fails: #!/bin/bash…
Jay Imerman
- 121
0
votes
1 answer
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 questions that need answered are stored in a file…
Kevin Rutan
- 57
0
votes
1 answer
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 and keep the same format as above. What I wrote: #/bin/bash…
0
votes
1 answer
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.e. Today -2). I have tried the below script but…
0
votes
2 answers
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]}@${my_array[3]} my_array=('something1'…
Phineas
- 103
-1
votes
2 answers
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 uninitialized_var [root@centos_8_0 scripts]# echo…
coyoteee3
- 1
- 1