Add tripleo-repos role

Add a role to install/run tripleo-repos

Change-Id: Ic75fb5bbdaaafb30dc90637edbbc169196ed8886
This commit is contained in:
Alex Schultz
2019-12-16 13:51:19 -07:00
parent 8c937edbae
commit 9ea41192a1
9 changed files with 162 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
tripleo-repos
=============
Role to install tripleo-repos and use it to manage tripleo yum repos.
Requirements
------------
None
Role Variables
--------------
* `tripleo_repos_branch`: (String) Repo branch to configure (master|train|stein|etc)
* `tripleo_repos_extra_args`: (List) List of extra arguments to pass to tripleo-repos
* `tripleo_repos_extra_repos`: (List) List of extra repos to configure (e.g. ceph)
* `tripleo_repos_repo_base`: (String) Url base to RDO (default: https://trunk.rdoproject.org)
* `tripleo_repos_version`: (String) Version to configure (current-tripleo-dev|current-tripleo|current)
Dependencies
------------
None
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- name: Setup tripleo-repos
include_role:
name: tripleo-repos
vars:
tripleo_repos_extra_repos:
- ceph
tripleo_repos_extra_args:
- "--rdo-mirror https://my.awesome.mirror/"
License
-------
Apache-2.0

View File

@@ -0,0 +1,7 @@
---
# defaults file for tripleo-repos
tripleo_repos_branch: master
tripleo_repos_extra_args: []
tripleo_repos_extra_repos: []
tripleo_repos_repo_base: https://trunk.rdoproject.org
tripleo_repos_version: current-tripleo-dev

View File

@@ -0,0 +1,2 @@
---
# handlers file for tripleo-repos

View File

@@ -0,0 +1,42 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
galaxy_info:
author: OpenStack
description: TripleO Operator Role -- tripleo-repos
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.8
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: CentOS
versions:
- 7
- 8
galaxy_tags:
- tripleo
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

View File

@@ -0,0 +1,31 @@
---
- name: Build distro string
set_fact:
_tripleo_repos_distro: "{{ (ansible_facts.distribution == 'RedHat') | ternary('rhel', 'centos') }}{{ ansible_facts.distribution_major_version }}"
- name: Build RDO repo url
set_fact:
_tripleo_repos_repo_url: "{{ tripleo_repos_repo_base }}/{{ _tripleo_repos_distro }}-{{ tripleo_repos_branch }}/current/"
- name: Find available tripleo-repos rpm
block:
- name: Grab repo package list
uri:
url: "{{ _tripleo_repos_repo_url }}"
return_content:
retries: 10
delay: 3
register: _tripleo_repos_repo_data
- name: Find rpm name
set_fact:
_tripleo_repos_rpm: "{{ _tripleo_repos_repo_data.content | regex_search('python[0-9]-tripleo-repos-[a-z0-9-.]+\\.rpm') }}"
- name: Fail if rpm is missing
fail:
msg: Unable to find tripleo-repos rpm
when: _tripleo_repos_rpm|length == 0
- name: Install tripleo-repos
yum:
name: "{{ _tripleo_repos_repo_url }}{{ _tripleo_repos_rpm }}"
state: present
become: true

View File

@@ -0,0 +1,27 @@
---
# tasks file for tripleo-repos
# TODO(mwhahaha): uncomment this once we have a version of ansible with
# https://github.com/ansible/ansible/pull/65776
#
# - name: Gather distribution facts
# setup:
# gather_subset: "!all,!min,distribution,distribution_major_version"
- name: Gather the rpm package facts
package_facts:
- name: Install tripleo-repos
include_tasks: install.yml
when: (ansible_facts.distribution_major_version|int <= 7 and not 'python2-tripleo-repos' in ansible_facts.packages) or
(ansible_facts.distribution_major_version|int <= 8 and not 'python3-tripleo-repos' in ansible_facts.packages)
- name: Run tripleo-repos
command: >-
tripleo-repos
-b {{ tripleo_repos_branch }}
{{ tripleo_repos_extra_args | join(' ') }}
{{ tripleo_repos_version }}
{{ tripleo_repos_extra_repos | join(' ') }}
become: true
changed_when: true

View File

@@ -0,0 +1,2 @@
localhost

View File

@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- tripleo-repos

View File

@@ -0,0 +1,2 @@
---
# vars file for tripleo-repos