only render main script if a manager type node

This commit is contained in:
m0duspwnens
2021-07-01 07:56:45 -04:00
parent 108fb12612
commit 21c9c7b8f4

View File

@@ -14,6 +14,8 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
{%- set role = grains.id.split('_') | last %}
{%- if role in ['manager', 'managersearch', 'eval', 'standalone'] %}
{%- import_yaml 'influxdb/defaults.yaml' as default_settings %} {%- import_yaml 'influxdb/defaults.yaml' as default_settings %}
{%- set influxdb = salt['grains.filter_by'](default_settings, default='influxdb', merge=salt['pillar.get']('influxdb', {})) %} {%- set influxdb = salt['grains.filter_by'](default_settings, default='influxdb', merge=salt['pillar.get']('influxdb', {})) %}
@@ -26,9 +28,8 @@ read -r -p "Are you sure you want to continue? [y/N] " yorn
if [[ "$yorn" =~ ^([yY][eE][sS]|[yY])$ ]]; then if [[ "$yorn" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo -e "\nDownsampling InfluxDb started at `date`. This may take several hours depending on how much data needs to be downsampled." echo -e "\nDownsampling InfluxDb started at `date`. This may take several hours depending on how much data needs to be downsampled."
{% for dest_rp in influxdb.downsample.keys() -%}
{% for dest_rp in influxdb.downsample.keys() %} {% for measurement in influxdb.downsample[dest_rp].get('measurements', []) -%}
{% for measurement in influxdb.downsample[dest_rp].get('measurements', []) %}
day=0 day=0
startdate=`date` startdate=`date`
@@ -49,11 +50,14 @@ if [[ "$yorn" =~ ^([yY][eE][sS]|[yY])$ ]]; then
fi fi
done done
{% endfor %} {% endfor -%}
{% endfor %} {% endfor -%}
echo -e "\nInfluxDb data downsampling complete." echo -e "\nInfluxDb data downsampling complete."
else else
echo -e "\nExiting as requested." echo -e "\nExiting as requested."
fi fi
{%- else %}
echo -e "\nThis script can only be run on a node running InfluxDB."
{%- endif %}