BigFix version of Ansible Task

I need to collect the content of an environment variable that points to a home directory of an specific app.

The env variable is set for an specific linux user and we already have an ansible script that pulls the content of the variable into a file. Now we are trying to achieve the same as we have environment where ansible is not available.

It’s always been a pain working with environment variables with BigFix. Here is the ansible piece:


    - name: we need to get the app home
      become_method: sudo
      become_flags: "-i"
      become_user: svc_app
      shell: echo $APP_HOME
      register: app_home_tmp

    - set_fact:
      app_home: "{{ app_home_tmp.stdout }}"

    - name: print debug statement
      debug:
        var: app_home

Here is what I have tried with BigFix but the output file is empty after executing the fixlet:

wait /bin/sh --login -c "sudo -i -u svc_app echo $APP_HOME > /var/opt/BESClient/EData/appversion.txt"

When you run this on the command line, does it return any data? I tested from the command line and this works for me:

sudo --user=username -i echo ‘$APP_HOME’ >/tmp/app_home.out

Throwing that into a BigFix task also produced the desired output.

-M

2 Likes

Unfortunately that didn’t work for my environment.

I ended up using


wait /bin/sh --login -c "sudo -i -u svc_app printenv APP_HOME > /var/opt/BESClient/EData/appversion.txt"

Do the environment inspectors not get the job done?

https://developer.bigfix.com/relevance/search/?query=environment

1 Like

Good point, I could have used the inspector to run it in an action using the runas command. I tried it as analysis and because the agent runs as root I was not getting what I needed and decided to use the native os commands.

This is a good usecase for this suggested idea.

Add a new “Scripted Properties” functionality that combines Properties and Actions
https://bigfix-ideas.hcltechsw.com/ideas/BFP-I-252