mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-07-29 02:44:41 +00:00
Issue #2: Remove extra test output data, adjust gitignore.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
*.retry
|
*.retry
|
||||||
.idea
|
.idea
|
||||||
*.log
|
*.log
|
||||||
|
tests/output
|
||||||
|
tests/integration/cloud-config-*
|
||||||
|
|||||||
3
tests/integration/targets/kubernetes/library/README.md
Normal file
3
tests/integration/targets/kubernetes/library/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# README
|
||||||
|
|
||||||
|
The `test_tempfile.py` module added here is only used for the `setup_remote_tmp_dir.yml` temporary directory setup task. It is a clone of the `tempfile.py` community-supported Ansible module, and has to be included with the tests here because it is not available in the `ansible-base` distribution against which this collection is tested.
|
||||||
120
tests/integration/targets/kubernetes/library/test_tempfile.py
Normal file
120
tests/integration/targets/kubernetes/library/test_tempfile.py
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright: (c) 2016, Krzysztof Magosa <krzysztof@magosa.pl>
|
||||||
|
# Copyright: (c) 2017, Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
|
'status': ['preview'],
|
||||||
|
'supported_by': 'community'}
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
---
|
||||||
|
module: test_tempfile
|
||||||
|
version_added: "2.3"
|
||||||
|
short_description: Creates temporary files and directories
|
||||||
|
description:
|
||||||
|
- The C(test_tempfile) module creates temporary files and directories. C(mktemp) command takes different parameters on various systems, this module helps
|
||||||
|
to avoid troubles related to that. Files/directories created by module are accessible only by creator. In case you need to make them world-accessible
|
||||||
|
you need to use M(file) module.
|
||||||
|
- For Windows targets, use the M(win_tempfile) module instead.
|
||||||
|
options:
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- Whether to create file or directory.
|
||||||
|
type: str
|
||||||
|
choices: [ directory, file ]
|
||||||
|
default: file
|
||||||
|
path:
|
||||||
|
description:
|
||||||
|
- Location where temporary file or directory should be created.
|
||||||
|
- If path is not specified, the default system temporary directory will be used.
|
||||||
|
type: path
|
||||||
|
prefix:
|
||||||
|
description:
|
||||||
|
- Prefix of file/directory name created by module.
|
||||||
|
type: str
|
||||||
|
default: ansible.
|
||||||
|
suffix:
|
||||||
|
description:
|
||||||
|
- Suffix of file/directory name created by module.
|
||||||
|
type: str
|
||||||
|
default: ""
|
||||||
|
seealso:
|
||||||
|
- module: file
|
||||||
|
- module: win_tempfile
|
||||||
|
author:
|
||||||
|
- Krzysztof Magosa (@krzysztof-magosa)
|
||||||
|
'''
|
||||||
|
|
||||||
|
EXAMPLES = """
|
||||||
|
- name: create temporary build directory
|
||||||
|
test_tempfile:
|
||||||
|
state: directory
|
||||||
|
suffix: build
|
||||||
|
|
||||||
|
- name: create temporary file
|
||||||
|
test_tempfile:
|
||||||
|
state: file
|
||||||
|
suffix: temp
|
||||||
|
register: tempfile_1
|
||||||
|
|
||||||
|
- name: use the registered var and the file module to remove the temporary file
|
||||||
|
file:
|
||||||
|
path: "{{ tempfile_1.path }}"
|
||||||
|
state: absent
|
||||||
|
when: tempfile_1.path is defined
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = '''
|
||||||
|
path:
|
||||||
|
description: Path to created file or directory
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
sample: "/tmp/ansible.bMlvdk"
|
||||||
|
'''
|
||||||
|
|
||||||
|
from os import close
|
||||||
|
from tempfile import mkstemp, mkdtemp
|
||||||
|
from traceback import format_exc
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(
|
||||||
|
state=dict(type='str', default='file', choices=['file', 'directory']),
|
||||||
|
path=dict(type='path'),
|
||||||
|
prefix=dict(type='str', default='ansible.'),
|
||||||
|
suffix=dict(type='str', default=''),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if module.params['state'] == 'file':
|
||||||
|
handle, path = mkstemp(
|
||||||
|
prefix=module.params['prefix'],
|
||||||
|
suffix=module.params['suffix'],
|
||||||
|
dir=module.params['path'],
|
||||||
|
)
|
||||||
|
close(handle)
|
||||||
|
elif module.params['state'] == 'directory':
|
||||||
|
path = mkdtemp(
|
||||||
|
prefix=module.params['prefix'],
|
||||||
|
suffix=module.params['suffix'],
|
||||||
|
dir=module.params['path'],
|
||||||
|
)
|
||||||
|
|
||||||
|
module.exit_json(changed=True, path=path)
|
||||||
|
except Exception as e:
|
||||||
|
module.fail_json(msg=to_native(e), exception=format_exc())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
- name: create temporary directory
|
- name: create temporary directory
|
||||||
tempfile:
|
test_tempfile:
|
||||||
state: directory
|
state: directory
|
||||||
suffix: .test
|
suffix: .test
|
||||||
register: remote_tmp_dir
|
register: remote_tmp_dir
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"clouds": {
|
|
||||||
"openshift": {
|
|
||||||
"platform": "openshift",
|
|
||||||
"setup_seconds": 63,
|
|
||||||
"targets": [
|
|
||||||
"k8s.k8s"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": {}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"clouds": {
|
|
||||||
"openshift": {
|
|
||||||
"platform": "openshift",
|
|
||||||
"setup_seconds": 19,
|
|
||||||
"targets": [
|
|
||||||
"k8s.k8s"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": {}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"clouds": {
|
|
||||||
"openshift": {
|
|
||||||
"platform": "openshift",
|
|
||||||
"setup_seconds": 19,
|
|
||||||
"targets": [
|
|
||||||
"k8s.k8s"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": {}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"clouds": {
|
|
||||||
"openshift": {
|
|
||||||
"platform": "openshift",
|
|
||||||
"setup_seconds": 20,
|
|
||||||
"targets": [
|
|
||||||
"kubernetes"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": {}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"clouds": {
|
|
||||||
"openshift": {
|
|
||||||
"platform": "openshift",
|
|
||||||
"setup_seconds": 19,
|
|
||||||
"targets": [
|
|
||||||
"kubernetes"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": {}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"clouds": {
|
|
||||||
"openshift": {
|
|
||||||
"platform": "openshift",
|
|
||||||
"setup_seconds": 19,
|
|
||||||
"targets": [
|
|
||||||
"kubernetes"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": {}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"clouds": {
|
|
||||||
"openshift": {
|
|
||||||
"platform": "openshift",
|
|
||||||
"setup_seconds": 19,
|
|
||||||
"targets": [
|
|
||||||
"kubernetes"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": {
|
|
||||||
"kubernetes": {
|
|
||||||
"aliases": [
|
|
||||||
"cloud/",
|
|
||||||
"cloud/kubernetes",
|
|
||||||
"cloud/openshift/",
|
|
||||||
"cloud/openshift/kubernetes",
|
|
||||||
"kubernetes",
|
|
||||||
"module/",
|
|
||||||
"module/kubernetes/",
|
|
||||||
"module/kubernetes/kubernetes",
|
|
||||||
"non_destructive/",
|
|
||||||
"non_destructive/kubernetes",
|
|
||||||
"posix/",
|
|
||||||
"role/",
|
|
||||||
"role/kubernetes",
|
|
||||||
"shippable/",
|
|
||||||
"shippable/cloud/",
|
|
||||||
"shippable/cloud/group1/",
|
|
||||||
"shippable/cloud/group1/kubernetes",
|
|
||||||
"shippable/cloud/kubernetes",
|
|
||||||
"shippable/kubernetes"
|
|
||||||
],
|
|
||||||
"coverage": false,
|
|
||||||
"coverage_label": "",
|
|
||||||
"modules": [
|
|
||||||
"kubernetes"
|
|
||||||
],
|
|
||||||
"name": "kubernetes",
|
|
||||||
"python_version": "3.6",
|
|
||||||
"run_time_seconds": 455,
|
|
||||||
"setup_always": [],
|
|
||||||
"setup_once": [],
|
|
||||||
"type": "role",
|
|
||||||
"validation_seconds": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user