Assumptions

For use with eg CentOS.

Assumes you have a file /etc/ansible/hosts with groups and members already configured.

A properly formatted .yml-file can be found at the end of the article.

---
- hosts: centos-cli:centos-srv
  gather_facts: no 
  tasks:   
  - name: upgrade centos-cr   
    ini_file:     
      dest: /etc/yum.repos.d/CentOS-CR.repo       
      section: cr     
      option: enabled       
      value: 1
...

 

Sources

https://github.com/ansible/ansible-modules-extras/issues/2384

https://stackoverflow.com/questions/44606514/ansible-2-3-1-0-enable-repo-on-centos-7

https://docs.ansible.com/ansible/2.5/modules/yum_repository_module.html

 

 

 

 

 

Hits: 492