<div dir="ltr">For Pulp 2.x, I use this plus some extra commands:<br><a href="https://docs.ansible.com/ansible/latest/modules/pulp_repo_module.html">https://docs.ansible.com/ansible/latest/modules/pulp_repo_module.html</a><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 9, 2019 at 9:48 AM Juan Cabrera <<a href="mailto:juan.cabrera@unamur.be">juan.cabrera@unamur.be</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p>Is there an ansible module to add or remove a rpm repository ?<br>
    </p>
    <p>I send in attachment the scripts I use for the moment to create
      and remove the rpm repositories.</p>
    <p>I use this:</p>
    <p><tt>vars:</tt></p>
    <tt> </tt>
    <p><tt>   - pulp_repos:</tt><tt><br>
      </tt><tt>       - repo: epel_ptci</tt><tt><br>
      </tt><tt>         remote: epel</tt><tt><br>
      </tt><tt>         remote_url: <a class="gmail-m_-127466067927007729moz-txt-link-freetext" href="https://epel.mirror.it2go.eu/7/x86_64/" target="_blank">https://epel.mirror.it2go.eu/7/x86_64/</a></tt><tt><br>
      </tt><tt>         state: present</tt></p>
    <tt> </tt>
    <p><tt>TODO: to become idempotent, check if repo already exists</tt></p>
    <tt> </tt>
    <p><tt>- name: config | Add repositories. </tt><tt><br>
      </tt><tt>   command: ~/create_repo --repo "{{ item.repo }}"
        --remote "{{ item.remote }}" --href "{{ item.remote_url }}"</tt><tt><br>
      </tt><tt>   loop: "{{ pulp_repos }}"</tt><tt><br>
      </tt><tt>   when: item.state is not defined or item.state ==
        'present'</tt><tt><br>
      </tt><tt>   become: yes</tt><tt><br>
      </tt><tt>   become_user: "{{ pulp_repo_user }}"</tt></p>
    <tt> </tt>
    <p><tt><br>
      </tt><tt> - name: config | Remove repositories</tt><tt><br>
      </tt><tt>   command: ~/remove_repo --repo "{{ item.repo }}"
        --remote "{{ item.remote }}"</tt><tt><br>
      </tt><tt>   loop: "{{ pulp_repos }}"</tt><tt><br>
      </tt><tt>   when: item.state is defined and item.state == 'absent'</tt><tt><br>
      </tt><tt>   become: yes</tt><tt><br>
      </tt><tt>   become_user: "{{ pulp_repo_user }}"</tt></p>
    <p>What is the best way to check if a repo already exist?</p>
    <p>Juan</p>
    <div class="gmail-m_-127466067927007729moz-signature">-- <br>
      <div style="font-family:Verdana,Helvetica,Arial,sans-serif;font-size:8pt;font-weight:normal;color:rgb(97,99,101)"> <img src="cid:16a026668fc6f16f3061" style="display: block; margin: 1em 0em;">
        <p style="margin:1em"> <span style="font-weight:bold">Juan
            CABRERA</span><br>
          <span style="color:rgb(105,190,40)">Correspondant informatique</span><br>
          <span>Département de Mathématiques</span> </p>
        <p style="margin:1em"> <span style="font-weight:bold">T.</span>
          081724919<br>
          <a style="color:rgb(105,190,40)" href="mailto:juan.cabrera@unamur.be" target="_blank">juan.cabrera@unamur.be</a><br>
          <a style="color:rgb(105,190,40)" href="http://staff.unamur.be/jbcabrer" target="_blank">http://staff.unamur.be/jbcabrer</a> </p>
        <p style="margin:1em"> <span style="font-weight:bold;font-size:8pt">Université de Namur ASBL</span><br>
          <span>Rue de Bruxelles 61 - 5000 Namur</span><br>
          <span>Belgique</span><br>
        </p>
        <p style="margin:1em;font-size:6pt;color:rgb(105,190,40)"> <span>Let’s
            respect the environment together.</span><br>
          <span style="font-weight:bold">Only print this message if
            necessary!</span><br>
        </p>
      </div>
    </div>
  </div>

_______________________________________________<br>
Pulp-list mailing list<br>
<a href="mailto:Pulp-list@redhat.com" target="_blank">Pulp-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-list" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-list</a></blockquote></div>