i set enviroment variable for elasticsearch-service in curator's config yml. and some env var in action_file.yml
i export variable in bash_profile file and other solution found in web but it does not work
there are two scenerio
1.when i run manually i.e.
curator --config /etc/config/config.yml /etc/config/action_file.yml >> /var/log/curator-(date +\%d\%b\%y_\%H\%M\%S).log
then it works as expected
2.when i run with crontab i.e.
0 * * * * curator --config /etc/config/config.yml /etc/config/action_file.yml >> /var/log/curator-(date +%d%b%y_%H%M%S).log
error in logs
ERROR Schema error: Configuration: filter: Location: Action ID "1", action "delete_indices", filter #1: {'filtertype': 'age', 'timestring': '%Y.%m.%d', 'direction': 'older'}: Bad Value: "(could not determine)", required key not provided @ data['source']. Check configuration file.
how to solve this issue of running crontab with using enviroment var in curator
This is typically because PATH and other environment variables that you normally have access to from the command-line are not automatically passed through to cron.
My personal recommendation is to make your one-liner into a simple shell script, and then have cron call that. Tweak it until all of the paths etc. are fully functional.
@theuntergeek
thanks for your solution
one more issue is there
if i make a enviroment variable for action file.
my action.yml
1:
action: delete_indices
description: >-
Delete indices older than (based on index name), for
prefixed indices. Ignore the error if the filter does not result in an
actionable list of indices (ignore_empty_list) and exit cleanly.
options:
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: regex
value: '^(testing-).*$'
- filtertype: age
timestring: '%Y.%m.%d'
source: name
direction: older
unit: days
#unit_count: 4
unit_count: ${RETENTION_PERIOD_FOR_TESTING}
my script where enviroment variable exported is - env-var.sh
So, that means that there is no value being passed—which, at closer look, is kind of not surprising:
ES_SVC=${ES_SVC}; export ES_SVC
How exactly can you pass the value of ES_SVC to itself? or RETENTION_PERIOD_FOR_TESTING to itself? You ought to be passing values to the environment variables. Here, you're passing the value of variables—which may or may not be set properly—to identically named variables. This would make it nearly impossible to cleanly troubleshoot.
At the very least, you should change the variable names to not be identical.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.