Coder Social home page Coder Social logo

ansible-yumrepo's Introduction

yumrepo

Role which helps to manage YUM repositories.

Examples

This role can be used either from a playbook (section roles):

---

- hosts: myhost
  roles:
    - role: yumrepo
      yumrepo_repos:
        myrepo1:
          name: My repo 1
          baseurl: http://myserver
          gpgcheck: 0
        myrepo2:
          name: My repo 2
          baseurl: http://myserver
          gpgcheck: 0

Or in the meta file (section dependencies):

galaxy_info:
  author: John Doe
  description: Role for App1
  license: MIT
  min_ansible_version: 1.7
  platforms:
    - name: Debian
      versions:
        - all
    - name: EL
      versions:
        - all
  categories:
    - web
dependencies:
  - role: yumrepo
    yumrepo_repos:
      myrepo2:
        name: My repo 3
        baseurl: http://myserver
        gpgcheck: 0

The role also supports managed mode which removes any repo which is not managed by this role.

---

# Example how to use the role in managed mode
- hosts: myhost
  vars:
    # This enables the managed mode
    yumrepo_manage: true

    # This prevents to delete CoreOS-Base repo file. Basically any repo file
    # which is not managed by the yumrepo role and is not listed in this variable
    # will be deleted.
    yumrepo_ignore_repo_files:
      - CentOS-Base
  roles:
    - role: yumrepo
      yumrepo_repos:
        myrepo4:
          name: My repo 4
          baseurl: http://myserver
    # When we finished with the setting of your YUM repos, we have to call the
    # role with the yumrepo_finish parameter to trigger the deletion of unmanaged
    # repos
    - role: yumrepo
      yumrepo_finish: true

If you are going to use the yumrepo across multiple plays in one playbook or in multiple playbooks, I recomend to create a shared file where you write the yumrepo_manage and the yumrepo_ignore_repo_files variables and then use it in every play the yumrepo role is used.

---

# This is the content of the shared file (e.g. vars/yumrepo.yaml)

# Enable managed mode
yumrepo_manage: true

# Ignore these repos
yumrepo_ignore_repo_files:
  - CentOS-Base
---

# This is the playbook with multiple plays using the shared file

- hosts: ~host[1-5]
  vars:
    # This is our shared file
    vars/yumrepo.yaml
  roles:
    - role: yumrepo
      yumrepo_repos:
        myrepo1:
          name: My repo 1
          baseurl: http://myserver
    - approle1

- hosts: ~host[3-5]
  vars:
    # This is our shared file
    vars/yumrepo.yaml
  roles:
    - role: yumrepo
      yumrepo_repos:
        myrepo1:
          name: My repo 2
          baseurl: http://myserver
    - approle2

# We can place the yum_finish into a separate play at the end of the playbook
- hosts: all
  vars:
    # This is our shared file
    vars/yumrepo.yaml
  roles:
    - role: yumrepo
      yumrepo_finish: true

The managed mode uses the /etc/yum.repos.d/.managed file which is generated by the role when the yumrepo_finish variable is set to true. This allows to create YUM repos across multiple roles and once all is done, it will generate the .managed file and clean the unmanaged repos.

Role variables

List of variables used by the role:

---

# If set to true, the management mode is enabled. That means that all unmanaged
# repos will be deleted). The best is to set it somewhere in a gobal variable
# file shared in all plays of the playbook.
yumrepo_manage: false

# Repository configuration
yumrepo_repos: []
# Example
#yumrepo_repos:
#  # ID of the repository
#  test:
#    # Additional parameters
#    name: Testing repo
#    baseurl: http://myserver/
#    enabled: 1
#    gpgcheck: 0
#    metadata_expire: 1

# Default list of repos files which won't be deleted during the clearing process
yumrepo_ignore_repos: []
# Example:
#yumrepo_ignore_repos:
#  - CentOS-Base

# To cleanup the temp directory and generate the .managed file
yumrepo_finish: false

License

MIT

Author

Jiri Tyr

ansible-yumrepo's People

Contributors

badmutex avatar bensallen avatar jtyr avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.