ansible Questions

By Michael P - January 31, 2020No Answers

hello,

I am trying to passwd the number of redhat release into the file:

 

    - name: To get the RHEL Release

      shell: cat /etc/redhat-release | awk '{ print $7 }' |cut -c1

      register: RH_REL

#

    - shell: touch /etc/yum.repos.d/wfpatch.repo

    - shell: echo [RHEL-{{ RH_REL }}-2020_{{ WW }}-OS] > /etc/yum.repos.d/patch.repo

 

 

 

but instead of just 1 number that should be = 6 or 7 (we run only rhel6 or 7)  , so instead I am getting all 

 

ok: [dmzpnet6.wellsfargo.net] => {

    "RH_REL": {

        "changed": true,

        "cmd": "cat /etc/yum.repos.d/rh_rel",

        "delta": "0:00:00.003045",

        "end": "2020-01-31 18:26:06.342559",

        "failed": false,

        "rc": 0,

        "start": "2020-01-31 18:26:06.339514",

        "stderr": "",

        "stderr_lines": [],

        "stdout": "7",

        "stdout_lines": [

            "7"

        ]

    }

}

 

 

how I can pass only 6  or 7   based on SO release ?

CMCrossroads is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.