Sunday, February 27, 2022

[SOLVED] ansible-playbook ansible-yum_repository writing to console

Issue

I have an playbook that does this:

- name: Add Copr Yum Repository
  yum_repository:
    name: czanik-syslog-ng-githead
    description: Copr repo for syslog-ng-githead owned by czanik
    baseurl: https://copr-be.cloud.fedoraproject.org/results/czanik/syslog-ng-githead/epel-7-$basearch/
    skip_if_unavailable: yes
    gpgkey: https://copr-be.cloud.fedoraproject.org/results/czanik/syslog-ng-githead/pubkey.gpg
    repo_gpgcheck: no
    enabled: yes

I run my playbook from cron every 15 minutes and every 15 minutes I see this ...

2019 Feb 16 20:45:31 sa-tool-001.example.com ansible-yum_repository Invoked with force=None directory_mode=None ip_resolve=None remote_src=None reposdir=/etc/yum.repos.d includepkgs=None owner=None bandwidth=None cost=None file=None exclude=None mirrorlist_expire=None follow=False attributes=None keepalive=None content=NOT_LOGGING_PARAMETER repo_gpgcheck=False src=None group=None failovermethod=None unsafe_writes=None delimiter=None deltarpm_metadata_percentage=None gpgkey=['https://copr-be.cloud.fedoraproject.org/results/czanik/syslog-ng-githead/pubkey.gpg'] setype=None http_caching=None priority=None serole=None mirrorlist=None params=None gpgcheck=None include=None proxy_username=None username=None metadata_expire=None description=Copr repo for syslog-ng-githead owned by czanik ui_repoid_vars=None selevel=None sslclientcert=None baseurl=['https://copr-be.cloud.fedoraproject.org/results/czanik/syslog-ng-githead/epel-7-$basearch/'] gpgcakey=None sslverify=None s3_enabled=None state=present sslcacert=None proxy_password=NOT_LOGGING_PARAMETER enablegroups=None regexp=None password=NOT_LOGGING_PARAMETER seuser=None retries=None protect=None ssl_check_cert_permissions=None throttle=None name=czanik-syslog-ng-githead deltarpm_percentage=None sslclientkey=None metalink=None enabled=True skip_if_unavailable=True keepcache=None mode=None timeout=None async=None metadata_expire_filter=None backup=None proxy=None

... get written to the console. It is very annoying, especially if you are editing a file as root or tailing output of some log file. How do I make it stop?


Solution

Set no_log: True in the task. This way, Ansible won’t log the task

- name: Add Copr Yum Repository
  yum_repository:
    name: czanik-syslog-ng-githead
    description: Copr repo for syslog-ng-githead owned by czanik
    baseurl: https://copr-be.cloud.fedoraproject.org/results/czanik/syslog-ng-githead/epel-7-$basearch/
    skip_if_unavailable: yes
    gpgkey: https://copr-be.cloud.fedoraproject.org/results/czanik/syslog-ng-githead/pubkey.gpg
    repo_gpgcheck: no
    enabled: yes
  no_log: True

You must set the variable for the whole task, not the yum module specifically.



Answered By - Kevin C
Answer Checked By - Dawn Plyler (WPSolving Volunteer)