Browse Source

Add support for managing clouds.yaml

Change-Id: If0d610998d1ebc858ee0cc133d4bc9f29450bf02
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
changes/32/623532/8
Paul Belanger 4 years ago
parent
commit
3ece8f7a25
  1. 15
      defaults/main.yaml
  2. 32
      tasks/config.yaml
  3. 5
      tasks/main.yaml
  4. 4
      templates/root/.config/openstack/clouds.yaml.j2
  5. 17
      tests/playbooks/run.yaml

15
defaults/main.yaml

@ -12,7 +12,22 @@
# License for the specific language governing permissions and limitations
# under the License.
---
# tasks/main.yaml
openstacksdk_task_manager:
- install
- config
# tasks/config.yaml
openstacksdk_user_name: root
openstacksdk_user_group: root
openstacksdk_user_home: /root
openstacksdk_file_clouds_yaml_dest: "{{ openstacksdk_user_home }}/.config/openstack/clouds.yaml"
openstacksdk_file_clouds_yaml_group: "{{ openstacksdk_user_group }}"
openstacksdk_file_clouds_yaml_mode: 0640
openstacksdk_file_clouds_yaml_owner: "{{ openstacksdk_user_name }}"
openstacksdk_file_clouds_yaml_src: root/.config/openstack/clouds.yaml.j2
openstacksdk_git_dest: "{{ ansible_user_dir }}/src/git.openstack.org/openstack/openstacksdk"
openstacksdk_git_uri: https://git.openstack.org/openstack/openstacksdk
openstacksdk_git_version: master

32
tasks/config.yaml

@ -0,0 +1,32 @@
# Copyright 2018 Red Hat, Inc.
#
# 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.
---
- name: Create required directories
become: true
become_user: "{{ openstacksdk_user_name }}"
file:
group: "{{ openstacksdk_user_group }}"
owner: "{{ openstacksdk_user_name }}"
path: "{{ openstacksdk_user_home }}/.config/openstack"
state: directory
- name: Install openstacksdk clouds.yaml
become: true
template:
dest: "{{ openstacksdk_file_clouds_yaml_dest }}"
group: "{{ openstacksdk_file_clouds_yaml_group }}"
mode: "{{ openstacksdk_file_clouds_yaml_mode }}"
owner: "{{ openstacksdk_file_clouds_yaml_owner }}"
src: "{{ openstacksdk_file_clouds_yaml_src }}"
register: openstacksdk_file_clouds_yaml

5
tasks/main.yaml

@ -15,4 +15,7 @@
- name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yaml"
- include: install.yaml
- include: "{{ openstacksdk_task }}.yaml"
with_items: "{{ openstacksdk_task_manager }}"
loop_control:
loop_var: openstacksdk_task

4
templates/root/.config/openstack/clouds.yaml.j2

@ -0,0 +1,4 @@
# This file is generated by Ansible
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
#
---

17
tests/playbooks/run.yaml

@ -20,7 +20,7 @@
- "{{ rolename }}"
post_tasks:
- name: Register openstacksdk_git_dest_stat.
- name: Register openstacksdk_git_dest_stat
stat:
path: /home/zuul/src/git.openstack.org/openstack/openstacksdk
register: openstacksdk_git_dest_stat
@ -32,3 +32,18 @@
- openstacksdk_git_dest_stat.stat.exists
- openstacksdk_git_dest_stat.stat.isdir
when: openstacksdk_install_method == 'git'
- name: Register openstacksdk_file_clouds_yaml
become: True
stat:
path: /root/.config/openstack/clouds.yaml
register: openstacksdk_file_clouds_yaml_stat
- name: Assert openstacksdk_file_clouds_yaml tests
assert:
that:
- openstacksdk_file_clouds_yaml_stat.stat.exists
- openstacksdk_file_clouds_yaml_stat.stat.isreg
- openstacksdk_file_clouds_yaml_stat.stat.pw_name == 'root'
- openstacksdk_file_clouds_yaml_stat.stat.gr_name == 'root'
- openstacksdk_file_clouds_yaml_stat.stat.mode == '0640'

Loading…
Cancel
Save