# How to disable \`gather\_facts\` and cowsays in \`ansible-test integration\`

**URL:** <https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120>\
**Category:** Get Help\
**Tags:** ansible-test, collections\
**Created:** [January 2, 2024, 7:56am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120 "2024-01-02T07:56:07Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumanth-lingappa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sumanth-lingappa/32/839_2.png) [@sumanth-lingappa](https://forum.ansible.com/u/sumanth-lingappa)\
**Post date:** [January 2, 2024, 7:56am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/1 "2024-01-02T07:56:07Z")

</div>

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

```zsh
❯ 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   

```

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 2, 2024, 8:11am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/2 "2024-01-02T08:11:07Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![sumanth-lingappa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sumanth-lingappa/32/839_2.png) [@sumanth-lingappa](https://forum.ansible.com/u/sumanth-lingappa)\
**Post date:** [January 2, 2024, 8:33am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/3 "2024-01-02T08:33:34Z")

</div>

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?

```bash
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   

```

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [January 2, 2024, 10:50am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/4 "2024-01-02T10:50:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [January 2, 2024, 11:41am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/5 "2024-01-02T11:41:35Z")

</div>

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

```bash
apt purge cowsay

```

---

<div class="post-metadata">

**Author:** ![sumanth-lingappa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sumanth-lingappa/32/839_2.png) [@sumanth-lingappa](https://forum.ansible.com/u/sumanth-lingappa)\
**Post date:** [January 2, 2024, 11:49am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/6 "2024-01-02T11:49:56Z")

</div>

I don’t want to uninstall cowsay @chris 🙂

---

<div class="post-metadata">

**Author:** ![mattclay](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mattclay/32/268_2.png) [@mattclay](https://forum.ansible.com/u/mattclay)\
**Post date:** [January 2, 2024, 10:15pm UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/7 "2024-01-02T22:15:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sumanth-lingappa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sumanth-lingappa/32/839_2.png) [@sumanth-lingappa](https://forum.ansible.com/u/sumanth-lingappa)\
**Post date:** [January 3, 2024, 5:24am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/8 "2024-01-03T05:24:04Z")

</div>

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?

> <https://github.com/ansible/ansible/blob/55065c00428cf857d501b7183ed8be34841f8025/test/lib/ansible_test/_internal/commands/integration/ __init__.py#L668>

---

<div class="post-metadata">

**Author:** ![mattclay](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mattclay/32/268_2.png) [@mattclay](https://forum.ansible.com/u/mattclay)\
**Post date:** [January 3, 2024, 5:42am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/9 "2024-01-03T05:42:39Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![sumanth-lingappa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sumanth-lingappa/32/839_2.png) [@sumanth-lingappa](https://forum.ansible.com/u/sumanth-lingappa)\
**Post date:** [January 3, 2024, 5:44am UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/10 "2024-01-03T05:44:31Z")

</div>

Thank you @mattclay

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

---

<div class="post-metadata">

**Author:** ![mattclay](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mattclay/32/268_2.png) [@mattclay](https://forum.ansible.com/u/mattclay)\
**Post date:** [January 3, 2024, 4:41pm UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/11 "2024-01-03T16:41:03Z")

</div>

The `/` is added here:

> <https://github.com/ansible/ansible/blob/ef1e01aa8b919ef8a9478c5c488bcd3a708ff517/test/lib/ansible_test/_internal/target.py#L676>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 2, 2024, 4:41pm UTC](https://forum.ansible.com/t/how-to-disable-gather-facts-and-cowsays-in-ansible-test-integration/3120/12 "2024-02-02T16:41:41Z")

</div>

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