Questions tagged [conditional]
The conditional tag has no usage guidance.
54
questions
2
votes
1
answer
175
views
IF Condition in Apache 2.4 is always executed
I am trying to load a module based on a condition.
{PHPMODULENAME} is replaced in the config by the AMP Server I am using - so please don't get confused.
<If "'{PHPMODULENAME}' == 'php8_module'...
2
votes
0
answers
198
views
Conditional directives based on User-Agent with Apache 2.2.x?
I want to implement something like the following in our Apache httpd configuration:
<If "%{HTTP_USER_AGENT} !~ /something/">
RemoveEncoding .gz .tgz
AddType ...
1
vote
1
answer
4k
views
Ansible conditional with variables and wildcards
Been trying to add a conditional with a wildcard and an Ansible variable and getting an error message. The idea is to trigger the api request with the container name starts with "android-", ...
1
vote
2
answers
374
views
Prevent OpenVPN systemd service from starting at home [closed]
Within my laptop PC, I set a systemd service that make a OpenVPN connection to my home, and let it automatically start on boot, so that I can access my home server anywhere.
The trouble is that when I'...
5
votes
1
answer
2k
views
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/...
0
votes
1
answer
602
views
How to set up conditional redirects on an Application Load Balancer for an Elastic Beanstalk environment?
I have two Docker-based single-instance Elastic Beanstalk environments (one for staging and one for production).
I'd like to migrate the (Elastic Beanstalk) application to sit behind a load balancer (...
1
vote
0
answers
611
views
how to make a redirect conditional on nginx conf
I should make a conditional rediction in nginx.
I would like to do something like that.
$http_code = code from curl commande
if ( $http_code = 200 ){
"redirection to server 1"
}
else {
"...
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 "...
0
votes
0
answers
44
views
Azure Application Proxy conditional access with linked applications
Linked applications, using AAD pre authentication, are no longer selectable options for my Conditional Access Policies. Early last week, I was able to add my internal linked applications to ...
0
votes
1
answer
868
views
How to redirect register output for failed hosts in ansible using assert or any ways
- name: Check the VolumeGroup has 5gb space
assert:
that: ansible_lvm.vgs.VG00.free_g|int >= 5
fail_msg: 'VG has no free space'
success_msg: "{{ ansible_lvm.vgs.rhel.free_g }}&...
0
votes
1
answer
7k
views
How can I add multiple conditions to a location-block conditional in NGINX configuration, or otherwise get same desired result?
Initial disclosure:
I'm new to nginx and struggling to understand its configuration principles; I have read a fair amount of the docs (including 'If Is Evil'), but still lack comprehension of many ...
1
vote
1
answer
346
views
Gitlab CI/CD with conditional scripts
Here is what I wish to do in GitLab CI/CD:
Whenever something is pushed into a specific branch I wish to have multiple scrips and CI/CD should decide which script should be run based on the pushed ...
0
votes
2
answers
1k
views
Ansible Variable Definition to Choose import_playbook From Inventory File
I'm using Ansible (V2.8) to build two different server environments that happen to support Drupal. They are very similar in terms of the settings for the OS, RDBMS, gluster, memcached, etc. But very ...
2
votes
1
answer
453
views
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 ...
1
vote
1
answer
1k
views
Puppet user creation with condition
How to create user with same UID(only if it doesn't exists) without affecting the servers having the same user with random UIDs.
To give more insight:
1. Maintain a user, "user1" all across the fleet ...
1
vote
3
answers
7k
views
Ansible - Is it possible to skip the execution of a role?
Here is my main playbook, which launch the roles listed below
---
- hosts: slaves
roles:
- ntp
- nmap
- tcpdump
- unattended-upgrades
- traceroute
- apache
...
0
votes
1
answer
1k
views
Using Azure Conditional Access to control downloading from SharePoint/OneDrive
I'm trying to use Azure Conditional Access to control downloading from SharePoint/OneDrive, but i'm completely new to this.
I wish to be able to use OneDrive (the business app) AND to download/sync ...
2
votes
1
answer
3k
views
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 ...
6
votes
1
answer
18k
views
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 / {
...
1
vote
2
answers
13k
views
SaltStack: Do x if /var/log/backup exists
I want to execute this state:
backup_log_readable:
acl.present:
- name: /var/log/backup
- acl_type: user
- acl_name: monitor
- perms: rx
- recurse: True
But this should happen ...
45
votes
3
answers
96k
views
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 ...
0
votes
1
answer
5k
views
How to whitelist User Agent string?
I'm trying to whitelist a very specific User Agent string in Nginx. The below examples demonstrate how to whitelist general types of browsers (eg mozilla or chrome), but the string I want to whitelist ...
-3
votes
1
answer
162
views
Function, that check previous command
i want to write fucntion, that check previous command. Succes or not.
My code:
#!/bin/bash
function check_previous {
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "success"
...
1
vote
1
answer
10k
views
Windows Server conditional forwarders does not work on one of the domain controllers
With few words, the problem is that few domain names are not resolved by workstations in our network, while doing it from Remote Desktop session on the server succeeds.
Now the details.
We have a ...
2
votes
0
answers
495
views
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 ...
1
vote
1
answer
2k
views
Ansible: trying to put conditionals on a vars file
I'm working on a project that will use a number of devices that will need to be configured with the same plays, but separate variables. I have a vars file which includes a number of libraries, one for ...
2
votes
2
answers
1k
views
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, ...
0
votes
1
answer
624
views
How can I script the shutdown of a host by a remote server when rsync completes and no users are logged in?
This is what I have so far. This script would run on a Network Services host that does things like DHCP etc... and in this instance should be waking and sleeping computers for backup.
#!/bin/bash
##...
4
votes
2
answers
2k
views
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 ]
...
1
vote
1
answer
96
views
Conditionals in cmd scripts
I'm doing scripting using appcmd. What I'd like to do is check to see if a given site exists and if does perform an action. In this case, delete it.
appcmd list app | find "mySite"
So, if the find "...
7
votes
2
answers
7k
views
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 ...
0
votes
1
answer
675
views
Install application inside docker container , only when it has not been installed before?
Is there a way to install any application inside docker container , only when it has not been installed before?
For example;
RUN apt-get install -y nginx
Will install nginx everytime on a new ...
1
vote
1
answer
377
views
Conditional dependencies in CHEF
I have a complicated software stack that I manage with 2 recipes.
recipe[stack::foo]
recipe[stack::bar]
foo is installed on every server, whereas bar is installed on only a subset of servers. bar ...
9
votes
1
answer
10k
views
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'...
1
vote
0
answers
596
views
AD DNS conditional forwarding returns short name instead of fqdn
First of all this isn't a copy of DNS Conditional forwarder returns NETBIOS instead of FQDN (just sounds very similar).
We have two separate domains that do conditional forwarding to eachother. Each ...
5
votes
5
answers
6k
views
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 ...
2
votes
1
answer
3k
views
exim route file condition [closed]
Using exim4 I have set up a route to use an external SMTP server. I am using cPanel which keeps a list of domains set up locally on the server in the file: /etc/localdomains . As a result I have set ...
0
votes
1
answer
1k
views
DNS Conditional forwarder returns NETBIOS instead of FQDN
Strange DNS problem for which I hope you can help.
Active Directory with NETBIOS name "Shortdomain" and as FQDN "verylongdomainname.lan". Domain controller DC01 behind firewall. IP: x.x.x.1
Customer ...
4
votes
0
answers
376
views
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:
<If "%{HTTP_HOST} =~ /[a-z]+/i">
Define test_value "A"
</If&...
2
votes
3
answers
2k
views
Write an apache configuration, with condition based on the apache version
I want to write a configuration for an apache server which should work for apache-2.2 and -2.4 without alterations. Since there are a quite a few new modules in v2.4 which have to be loaded,and a few ...
0
votes
1
answer
281
views
Nginx: security vs conditionals
I was reading around looking for some security steps that can be taken in Nginx to protect apps I'm serving using Nginx as a reverse proxy. I found this code which has some good things in it to ...
1
vote
2
answers
3k
views
Conditionally Rewrite Email Headers (From & Reply-To) Exchange 2010
I have a client who maintains Company A (with email addresses %username%@companyA.com) and they own the domain companyB.com however there is no "infrastructure" (no Exchange server) set up ...
0
votes
3
answers
798
views
EXIM - Send local mail to Gateway First
My mail server is protected from spam by our Barracuda appliance. I'm trying to configure EXIM to forward ALL outbound messages to the Barracuda server first, including mail for local domains. Once ...
2
votes
2
answers
3k
views
Nginx - Apply basic auth only if an htaccess file exists
How can I apply basic auth only if an htaccess file exists?
If first tried to put the auth_basic directives in an if block, but
that is not allowed.
Then, I tried redirecting to a named location, ...
4
votes
1
answer
3k
views
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 ...
0
votes
1
answer
3k
views
Postfix conditional rules base on sending address
Email configuration on dev server: At the moment I have postfix configured to route all emails sent to itself. So if you try to send and email to any address say [email protected] it won't be ...
3
votes
2
answers
7k
views
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:
<...
1
vote
1
answer
2k
views
apache if ie send some header
I want to set some headers just for MSIE using apache configuartion file. How can i set the condition for that ?
# better website experience for ie users
<IfModule mod_headers.c && MSIE>...
0
votes
1
answer
397
views
Rebuilding a file if files have changed
I'm having a hard time wrapping my head around this. It seems trivial, but I'm not getting it.
I have two files. If either of those two files changes, I want to rebuild one of them.
Essentially:
...
0
votes
1
answer
95
views
Discerning which GNU screen window is being used in a shell script
Using a shell script, how can you tell if a screen is running using shell scripts?
For example, using pseudocode:
IF (screen.screenname.running == TRUE)
or something like that.