Skip to content

Commit

Permalink
vagrant: support custom yum repos for local caching
Browse files Browse the repository at this point in the history
Add new global vars that support defining custom, possibly locally
caching, yum repos in place of the normal repos for epel, gluster, and
kubernetes pacakages. Add a new /etc/hosts tweaking variable to
support the custom yum server (and docker registry) better.

This has been tested running pulp on another VM.

Signed-off-by: John Mulligan <[email protected]>
  • Loading branch information
phlogistonjohn authored and jarrpa committed Nov 4, 2017
1 parent 861d2e0 commit f0aa538
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
26 changes: 25 additions & 1 deletion vagrant/global_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ install_pkgs:
- kubectl{{ kubernetes_version_tag }}
- ntp
# The following variables control the use and configuration of a custom docker
# registry:
# registry and/or custom rpm repositories:
# * custom_registry: Specifies and enables a custom registry (default none)
# * custom_registry_insecure: Marks the custom registry as insecure. This is
# typically the case if you're running a local registry on your host machine
Expand All @@ -37,9 +37,33 @@ install_pkgs:
# Valid values are 'present' and 'absent'. (default 'present')
# * gcr_proxy_nginx: The version of nginx-slim to use for the gcr.io proxy.
# (default '0.8')
# * custom_yum_repos: Define custom yum repos as mapping of repo names
# (short strings) to repo urls. One or more repo must be specified if this
# option is enabled. Using this option will disable the normal user of
# the centos epel, centos gluster, and google kubernetes repos.
# * custom_host_aliases: If the custom_repos or registry refer to hostnames
# that cannot be resolved normally a custom_host_aliases variable can be
# used to add specific entries to /etc/hosts.
#custom_registry: 192.168.10.1:5000
#custom_registry_insecure: false
#custom_registry_add: false
#custom_registry_gcr: true
#gcr_proxy_state: absent
#gcr_proxy_nginx: 0.23
#custom_yum_repos:
# kubernetes_el7: http://mypkgs/path/to/repo1
# epel_el7: http://mypkgs/path/to/repo2
# gluster_el7: http://mypkgs/another/repo/path/repo3
#custom_host_aliases:
# - addr: 192.168.122.164
# names:
# - mypkgs
# - mypkgs.localdomain
# - rpms.example.com
# - addr: 192.168.122.168
# names:
# - marble
# - addr: 192.168.122.169
# names:
# - jimmy
# - cricket
52 changes: 38 additions & 14 deletions vagrant/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,44 @@
- cache_exists.stat.exists == True
- vagrant_cache

- name: install centos and epel repos
yum:
name: "{{ item }}"
state: present
with_items:
- epel-release
- centos-release-gluster

- name: setup kubernetes repo
yum_repository:
name: kubernetes
description: Kubernetes
baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled: yes
- name: customize hosts file
lineinfile: dest=/etc/hosts line="{{ item.addr }} {{ item.names | join(\" \") }}"
when: custom_host_aliases is defined
with_items: "{{ custom_host_aliases | default(omit) }}"

- block:
# setup standard repos
- name: install centos and epel repos
yum:
name: "{{ item }}"
state: present
with_items:
- epel-release
- centos-release-gluster

- name: setup kubernetes repo
yum_repository:
name: kubernetes
description: Kubernetes
baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled: yes
when: custom_repos is not defined

- block:
- name: setup custom yum repos
yum_repository:
name: "{{ item.key }}"
description: "Custom-Repo-{{ item.key }}"
baseurl: "{{ item.value }}"
enabled: yes
with_dict: "{{ custom_yum_repos }}"

- name: disable yum fastestmirror plugin
lineinfile:
path: /etc/yum/pluginconf.d/fastestmirror.conf
regexp: "^enabled="
line: enabled=0
when: custom_yum_repos is defined

- name: install base packages
yum:
Expand Down

0 comments on commit f0aa538

Please sign in to comment.