├── ansible.cfg ├── vars └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── test.yml ├── defaults └── main.yml ├── tasks └── main.yml ├── README.md ├── templates ├── epel-testing.repo.j2 └── epel.repo.j2 └── files └── RPM-GPG-KEY-EPEL-7 /ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | roles_path = ../ 3 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for ansible-role-repo-epel 3 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for ansible-role-repo-epel 3 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: z 4 | description: Configure EPEL Repo for RedHat/CentOS. 5 | company: 6 | license: license (BSD, MIT) 7 | min_ansible_version: 1.2 8 | platforms: 9 | - name: EL 10 | versions: 11 | - 6 12 | - 7 13 | categories: 14 | - system 15 | dependencies: [] 16 | -------------------------------------------------------------------------------- /test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # test file 3 | 4 | - name: Install epel repo. 5 | hosts: servers 6 | roles: 7 | - role: ansible-role-repo-epel 8 | repo_epel_baseurl: http://mirrors.ustc.edu.cn/epel/7/x86_64/ 9 | #repo_epel_mirrorlist: "https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch" 10 | repo_epel_rpm: False 11 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for ansible-role-repo-epel 3 | 4 | repo_epel_rpm: True 5 | repo_epel_baseurl: "" 6 | #repo_epel_baseurl: http://download.fedoraproject.org/pub/epel/7/$basearch 7 | repo_epel_mirrorlist: "" 8 | #repo_epel_mirrorlist: "https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch" 9 | repo_epel_backup: no 10 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for ansible-role-repo-epel 3 | 4 | - name: Install the epel rpm package. 5 | yum: name=epel-release state=installed 6 | when: repo_epel_rpm 7 | 8 | - name: Configurage epel repo files. 9 | template: src=epel.repo.j2 dest='/etc/yum.repos.d/epel.repo' backup={{ repo_epel_backup }} 10 | when: not repo_epel_rpm 11 | 12 | - name: Configurage epel-testing repo files. 13 | template: src=epel-testing.repo.j2 dest=/etc/yum.repos.d/epel-testing.repo backup={{ repo_epel_backup }} 14 | when: not repo_epel_rpm 15 | 16 | - name: Prepare the GPG key for epel. 17 | copy: src=RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }} dest=/etc/pki/rpm-gpg 18 | when: not repo_epel_rpm 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: repo-epel 2 | 3 | Configure EPEL Repo for RedHat/CentOS. 4 | 5 | ## Requirements 6 | 7 | repo_epel_baseurl和repo_epel_mirrorlist同时只能设置一个. 8 | 9 | ## Role Variables 10 | 11 | `defaults/main.yml` 12 | 13 | * `repo_epel_rpm: True` 14 | * `repo_epel_baseurl: ""` 15 | * `repo_epel_mirrorlist: ""` 16 | * `repo_epel_backup: no` 17 | 18 | 19 | ## Dependencies 20 | 21 | None. 22 | 23 | ## Example Playbook 24 | 25 | - name: Install epel repo. 26 | hosts: servers 27 | roles: 28 | - role: ansible-role-repo-epel 29 | repo_epel_rpm: False 30 | repo_epel_baseurl: http://mirrors.ustc.edu.cn/epel/7/x86_64/ 31 | 32 | ## License 33 | 34 | MIT / BSD 35 | 36 | ## Author Information 37 | 38 | z 39 | -------------------------------------------------------------------------------- /templates/epel-testing.repo.j2: -------------------------------------------------------------------------------- 1 | [epel-testing] 2 | name=Extra Packages for Enterprise Linux {{ ansible_distribution_major_version }} - Testing - $basearch 3 | #baseurl=http://download.fedoraproject.org/pub/epel/testing/{{ ansible_distribution_major_version }}/$basearch 4 | mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-epel{{ ansible_distribution_major_version }}&arch=$basearch 5 | failovermethod=priority 6 | enabled=0 7 | gpgcheck=1 8 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }} 9 | 10 | [epel-testing-debuginfo] 11 | name=Extra Packages for Enterprise Linux {{ ansible_distribution_major_version }} - Testing - $basearch - Debug 12 | #baseurl=http://download.fedoraproject.org/pub/epel/testing/{{ ansible_distribution_major_version }}/$basearch/debug 13 | mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel{{ ansible_distribution_major_version }}&arch=$basearch 14 | failovermethod=priority 15 | enabled=0 16 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }} 17 | gpgcheck=1 18 | 19 | [epel-testing-source] 20 | name=Extra Packages for Enterprise Linux {{ ansible_distribution_major_version }} - Testing - $basearch - Source 21 | #baseurl=http://download.fedoraproject.org/pub/epel/testing/{{ ansible_distribution_major_version }}/SRPMS 22 | mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel{{ ansible_distribution_major_version }}&arch=$basearch 23 | failovermethod=priority 24 | enabled=0 25 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }} 26 | gpgcheck=1 27 | -------------------------------------------------------------------------------- /templates/epel.repo.j2: -------------------------------------------------------------------------------- 1 | [epel] 2 | name=Extra Packages for Enterprise Linux {{ ansible_distribution_major_version }} - $basearch 3 | #baseurl=http://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/$basearch 4 | #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-{{ ansible_distribution_major_version }}&arch=$basearch 5 | {% if repo_epel_baseurl %} 6 | baseurl={{ repo_epel_baseurl }} 7 | {% endif %} 8 | {% if repo_epel_mirrorlist %} 9 | mirrorlist={{ repo_epel_mirrorlist }} 10 | {% endif%} 11 | failovermethod=priority 12 | enabled=1 13 | gpgcheck=1 14 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }} 15 | 16 | [epel-debuginfo] 17 | name=Extra Packages for Enterprise Linux {{ ansible_distribution_major_version }} - $basearch - Debug 18 | #baseurl=http://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/$basearch/debug 19 | mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-{{ ansible_distribution_major_version }}&arch=$basearch 20 | failovermethod=priority 21 | enabled=0 22 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }} 23 | gpgcheck=1 24 | 25 | [epel-source] 26 | name=Extra Packages for Enterprise Linux {{ ansible_distribution_major_version }} - $basearch - Source 27 | #baseurl=http://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/SRPMS 28 | mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-{{ ansible_distribution_major_version }}&arch=$basearch 29 | failovermethod=priority 30 | enabled=0 31 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }} 32 | gpgcheck=1 33 | -------------------------------------------------------------------------------- /files/RPM-GPG-KEY-EPEL-7: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v1.4.11 (GNU/Linux) 3 | 4 | mQINBFKuaIQBEAC1UphXwMqCAarPUH/ZsOFslabeTVO2pDk5YnO96f+rgZB7xArB 5 | OSeQk7B90iqSJ85/c72OAn4OXYvT63gfCeXpJs5M7emXkPsNQWWSju99lW+AqSNm 6 | jYWhmRlLRGl0OO7gIwj776dIXvcMNFlzSPj00N2xAqjMbjlnV2n2abAE5gq6VpqP 7 | vFXVyfrVa/ualogDVmf6h2t4Rdpifq8qTHsHFU3xpCz+T6/dGWKGQ42ZQfTaLnDM 8 | jToAsmY0AyevkIbX6iZVtzGvanYpPcWW4X0RDPcpqfFNZk643xI4ls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LKwlUjGPAjYflpCQwWMAASxiv9uPyYPHc 25 | ErSrbRG0wjIfAR3vus1OSOx3xZHZpXFfmQTsDP7zVROLzV98R3JwFAxJ4/xqeON4 26 | vCPFU6OsT3lWQ8w7il5ohY95wmujfr6lk89kEzJdOTzcn7DBbUru33CQMGKZ3Evt 27 | RjsC7FDbL017qxS+ZVA/HGkyfiu4cpgV8VUnbql5eAZ+1Ll6Dw== 28 | =hdPa 29 | -----END PGP PUBLIC KEY BLOCK----- 30 | --------------------------------------------------------------------------------