Browse Source

import of the role

Change-Id: Id2cd819def3e83f92fcd8126a74aa19690dcf4c8
changes/83/724683/5
Gonéri Le Bouder 2 years ago
parent
commit
822a950d43
  1. 42
      README.rst
  2. 9
      bindep.txt
  3. 32
      defaults/main.yaml
  4. 73
      doc/source/conf.py
  5. 1
      doc/source/index.rst
  6. 31
      meta/main.yml
  7. 30
      tasks/config.yaml
  8. 20
      tasks/install.yaml
  9. 18
      tasks/main.yaml
  10. 1
      templates/root/.aws/credentials.j2
  11. 1
      tests/inventory
  12. 9
      tests/playbooks/pre.yaml
  13. 36
      tests/playbooks/run.yaml

42
README.rst

@ -0,0 +1,42 @@
==================
ansible-role-boto3
==================
Ansible role to install AWS's boto3 library
* License: Apache License, Version 2.0
* Documentation: https://ansible-role-boto3.readthedocs.org
* Source: https://git.openstack.org/cgit/openstack/ansible-role-boto3
* Bugs: https://bugs.launchpad.net/ansible-role-boto3
Description
-----------
AWS's boto3 is a simple client library for operating AWS.
Requirements
------------
See `bindep.txt` for role dependencies.
Packages
~~~~~~~~
Package repository index files should be up to date before using this role, we
do not manage them.
Role Variables
--------------
Dependencies
------------
Example Playbook
----------------
.. code-block:: yaml
- name: Install AWS's Boto3 lib
hosts: nodepool
roles:
- ansible-role-boto3

9
bindep.txt

@ -0,0 +1,9 @@
# This is a cross-platform list tracking distribution packages needed by tests;
# see http://docs.openstack.org/infra/bindep/ for additional information.
git
libffi-devel [platform:rpm]
libffi-dev [platform:dpkg]
libssl-dev [platform:dpkg]
openssl-devel [platform:rpm]
python2-dnf [platform:fedora]

32
defaults/main.yaml

@ -0,0 +1,32 @@
# Copyright 2015-2020 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.
---
# tasks/main.yaml
boto3_task_manager:
- install
- config
# tasks/config.yaml
boto3_user_name: root
boto3_user_group: root
boto3_user_home: /root
boto3_file_credentials_dest: "{{ boto3_user_home }}/.aws/credentials"
boto3_file_credentials_group: "{{ boto3_user_group }}"
boto3_file_credentials_mode: 0640
boto3_file_credentials_owner: "{{ boto3_user_name }}"
boto3_file_credentials_src: root/.aws/credentials.j2
boto3_pip_name: boto3
# boto3_pip_virtualenv: /root/venv

73
doc/source/conf.py

@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
# 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.
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
# -- General configuration ----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.autodoc',
]
# autodoc generation is a bit aggressive and a nuisance when doing heavy
# text edit cycles.
# execute "export SPHINX_DEBUG=1" in your terminal to disable
# The suffix of source filenames.
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'ansible-role-openstacksdk'
copyright = u'2013, OpenStack Foundation'
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
add_module_names = True
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# -- Options for HTML output --------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
# html_theme_path = ["."]
# html_theme = '_theme'
# html_static_path = ['static']
# Output file base name for HTML help builder.
htmlhelp_basename = '%sdoc' % project
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
('index',
'%s.tex' % project,
u'%s Documentation' % project,
u'OpenStack Foundation', 'manual'),
]
# Example configuration for intersphinx: refer to the Python standard library.
# intersphinx_mapping = {'http://docs.python.org/': None}

1
doc/source/index.rst

@ -0,0 +1 @@
.. include:: ../../README.rst

31
meta/main.yml

@ -0,0 +1,31 @@
# Copyright 2015-2020 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.
---
galaxy_info:
author: Gonéri Le Bouder
description: Boto3 library for AWS
company: Red Hat, Inc.
license: Apache
min_ansible_version: 2.4
platforms:
- name: Fedora
versions:
- 31
- name: Ubuntu
versions:
- 18.04
- 20.04
categories:
- system
dependencies: []

30
tasks/config.yaml

@ -0,0 +1,30 @@
# Copyright 2020 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 the .aws
become: true
file:
group: "{{ boto3_user_group }}"
owner: "{{ boto3_user_name }}"
path: "{{ boto3_user_home }}/.aws"
state: directory
- name: Generate the AWS credentials file
become: true
template:
group: "{{ boto3_user_group }}"
owner: "{{ boto3_user_name }}"
dest: "{{ boto3_user_home }}/.aws/credentials"
mode: "{{ boto3_file_credentials_mode }}"
src: "{{ boto3_file_credentials_src }}"

20
tasks/install.yaml

@ -0,0 +1,20 @@
# Copyright 2020 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: Install boto3 using pip
become: true
become_user: "{{ boto3_user_name }}"
pip:
name: "{{ boto3_pip_name }}"
virtualenv: "{{ boto3_pip_virtualenv|default(omit) }}"

18
tasks/main.yaml

@ -0,0 +1,18 @@
# Copyright 2020 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.
---
- include: "{{ boto3_task }}.yaml"
with_items: "{{ boto3_task_manager }}"
loop_control:
loop_var: boto3_task

1
templates/root/.aws/credentials.j2

@ -0,0 +1 @@
# Default credentials template

1
tests/inventory

@ -0,0 +1 @@
localhost

9
tests/playbooks/pre.yaml

@ -0,0 +1,9 @@
---
- hosts: all
tasks:
- name: Disable extra wheels mirror
become: true
lineinfile:
dest: /etc/pip.conf
regexp: ^extra-index-url
state: absent

36
tests/playbooks/run.yaml

@ -0,0 +1,36 @@
# Copyright 2015-2020 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.
---
- hosts: all
vars:
rolename: ansible-role-boto3
roles:
- "{{ rolename }}"
post_tasks:
- name: Register aws_credentials_file_stat
become: true
stat:
path: /root/.aws/credentials
register: aws_credentials_file_stat
- name: Assert aws_credentials_file_stat tests
assert:
that:
- aws_credentials_file_stat.stat.exists
- aws_credentials_file_stat.stat.isreg
- aws_credentials_file_stat.stat.pw_name == 'root'
- aws_credentials_file_stat.stat.gr_name == 'root'
- aws_credentials_file_stat.stat.mode == '0640'
Loading…
Cancel
Save