How to disable `gather_facts` and cowsays in `ansible-test integration`

I am unable to disable gathering_facts and cowsay even when they are disabled in my environent variable and ~/.ansible.cfg file

❯ cat ~/.ansible.cfg
[defaults]
gathering = explicit
nocows = 1


❯ echo $ANSIBLE_NOCOWS
1

❯ echo $ANSIBLE_GATHERING
explicit

❯ ansible-test integration 
Running nsip integration test role
 _________________ 
< PLAY [testhost] >
 ----------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

 ________________________ 
< TASK [Gathering Facts] >
 ------------------------ 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [testhost]
 __________________________________ 
< TASK [nsip : Add NSIP | --check] >
 ---------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

changed: [testhost -> localhost]
 _______________________________________ 
< TASK [nsip : Assert on add | --check] >
 --------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

 ____________ 
< PLAY RECAP >
 ------------ 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

testhost                   : ok=2   changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

I’ve never seen cowsay being used in ansible-test integration. Can you provide more information on your environment, or preferably a way to reproduce it? (Maybe starting with an empty container so it’s easy to fully reproduce the environment.)

You are right @felixfontein.

I tried in an empty container and I didn’t get the cowsay

Do you guess any problem in my environment?

root@008c7af128a2:/ansible_collections/netscaler/adc# ansible-test integration
WARNING: Using locale "C.UTF-8" instead of "en_US.UTF-8". Tests which depend on the locale may behave unexpectedly.
Running nsip integration test role

PLAY [testhost] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [testhost]

PLAY RECAP *********************************************************************
testhost                   : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

I guess there is, but I don’t know what could trigger this. Maybe @mattclay has an idea?

Uninstall cowsay? If you are running a Debian based distro:

apt purge cowsay

I don’t want to uninstall cowsay @chris :slight_smile:

Fact gathering can be disabled in individual integration tests by adding gather_facts/no to the aliases file for that test.

Currently the only way to prevent cowsay from being used is to ensure it’s not present on the system running the tests. The --docker option is one way to accomplish that.

2 Likes

Thank you @mattclay, your suggestion to include gather_facts/no helped me to stop gathering facts.

However, I looked into the ansible/ansible code.

In the below line, it is checking for gather_facts/no/ (the last slash) in the target.aliases.

How does gather_facts/no (without the last slash) work?

Am I missing something?

Internally, ansible-test adds a trailing / to most aliases during parsing, so gather_facts/no becomes gather_facts/no/ by the time it’s saved in target.aliases.

Thank you @mattclay

Can I please ask you the code in the ansible repo? (I hope I am not asking too much :crossed_fingers: )

The / is added here:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.