Questions tagged [conditional]

54 questions
39
votes
3 answers

Is there a way to check that a dictionary key is not defined in ansible task?

So in my code I have a task - name: cool task shell: 'touch iamnotcool.txt' when: me.cool is not defined and my vars looks like --- me: stumped: yes So when I run the task it comes back with the following error {"failed": true, "msg": "The…
Luis F Hernandez
  • 633
  • 1
  • 7
  • 9
8
votes
1 answer

Can someone explain nginx conditional flags? (-f, -d, -e, etc)

I'm in the process of migrating from Apache to nginx and have used http://winginx.com/en/htaccess to migrate the rewrite rules. I'm trying to understand what the translated ones mean though and I can't find any documentation on it. Here's an…
6
votes
2 answers

Ansible conditional statement based on other roles?

I've got the following scenario with an Ansible deployment: hostX has the role common-mta and a few other roles hostY has the role common-mta as well as the role package-postfix The common-mta role copies a file (if you could have guessed, it's…
Joshua Boniface
  • 324
  • 3
  • 14
5
votes
1 answer

How do I properly write an "or" statement in an Nginx location block?

I'm using Nginx on CentOS 7. I want to add a cache control header for files that end in a particular extension or taht contain a "/image/" string in the URL. I tried this location / { proxy_pass http://scale; # match the name of upstream…
Dave
  • 155
  • 1
  • 5
  • 17
5
votes
5 answers

Need to check whether you need to reboot for a kernel update?

I'm using Ansible to check hosts if they need to be rebooted if the /vmlinuz kernel doesn't resolve to uname -r. The if condition is although always identifing a reboot even though the test machine has been rebooted and the kernel is resolving to…
nicoX
  • 611
  • 9
  • 18
4
votes
2 answers

bash if statment unexpected behavior in crontab job

Here is the script bash --version | head -n1 if [ "$1" == "now" ] then echo if now execut job else echo else "_"$1"_" # make sure we are not picking any spaces if [ condition ] then execut something else …
Nabil Sham
  • 267
  • 1
  • 2
  • 9
4
votes
0 answers

Unable to match expression inside If directive no matter what

I have been trying for the past 3 hours trying to match an if statement to define a variable within httpd.conf with no success: Define test_value "A" Define test_value "B" I have tried:
Question Overflow
  • 2,023
  • 7
  • 28
  • 44
4
votes
1 answer

Apache2 conditional section based on port

I don't know much about if statements in apache configuration, and I'm wondering if I can have a section of the configuration applied only if the request is received on a certain port. In short, this is about SSL. I have name based virtual hosts, I…
Waleed Hamra
  • 731
  • 6
  • 16
4
votes
1 answer

Conditional blocks of code in linux bash

Nearly everybody knows very useful && and || operators, for example: rm myf && echo "File is removed successfully" || echo "File is not removed" I've got a question: how to put a block of commands after && or || operators without using the…
Arek
  • 155
  • 4
  • 9
3
votes
2 answers

Apache: Set global headers only if not already set

I am having a little annoying situation here. I have a server managed by plesk. In the /etc/apache2/apache2.conf mod_headers and mod_expires based configuration takes place. For example: Header set…
func0der
  • 154
  • 4
  • 15
3
votes
1 answer

Is it impossible to have conditional headers in Nginx?

I am currently trying to only return a set of CORS headers conditionally using Nginx. At first it seemed like a simple task, as I already had this working config: upstream api-app { server unix:/tmp/api-app.sock fail_timeout=0; } server { …
2
votes
1 answer

Is it possible to make IfFile work on Apache 2.4.29 for Ubuntu 18.04, and if so, how?

I am wanting to conditionally load VirtualHosts depending on the existance of the appropriate key files required for SSL for that virtualhost (or failing which, have a generic certificate I can fall back to), and I've been unable to find a way to…
davidgo
  • 5,964
  • 2
  • 21
  • 38
2
votes
1 answer

Ansible | Access multi dimensional variable for when conditional in nested loop task

I try to use a conditional when inside a task with a nested loop. Specifically first of all I want to read different states per user, register the variable after that and want to iterate over this variable in another task. Register the variable: -…
biotecs
  • 21
  • 3
2
votes
0 answers

apache conditional statements - what is the processing order?

I try to protect the access to a subdirectory by http auth using .htaccess file configuration. This is the full working code for apache 2.4 in my case. # Conditionally set environment variable BACKEND_PROTECTION (version for apache 2.4)
2
votes
2 answers

Is there a way to only push routes via OpenVPN under certain conditions?

Abstract question: In my OpenVPN client setup I'd like to set routes pushed by the server only under certain conditions. Concrete situation: I am using a laptop, that, when I am at the office, connects to our companys infrastructure via its gateway.…
HannesS
  • 322
  • 5
  • 17
1
2 3 4