Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kubespray
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Kubespray
Commits
cd2847c1
Commit
cd2847c1
authored
9 years ago
by
ant31
Committed by
Smana
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add kpm role
parent
309d6a49
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
library/kpm.py
+104
-0
104 additions, 0 deletions
library/kpm.py
roles/kubernetes-apps/defaults/main.yaml
+4
-0
4 additions, 0 deletions
roles/kubernetes-apps/defaults/main.yaml
roles/kubernetes-apps/tasks/main.yaml
+9
-0
9 additions, 0 deletions
roles/kubernetes-apps/tasks/main.yaml
with
117 additions
and
0 deletions
library/kpm.py
0 → 100644
+
104
−
0
View file @
cd2847c1
#!/usr/bin/python
# -*- coding: utf-8 -*-
import
kpm.deploy
from
ansible.module_utils.basic
import
*
DOCUMENTATION
=
"""
---
module: kpm
short_description: Application deployment on kubernetes with kpm registry
description:
- Create, remove, and update resources within a Kubernetes Cluster
version_added:
"
2.0
"
options:
name:
required: true
default: null
description:
- The name of the kpm package
namespace:
required: false
default:
'
default
'
description:
- The namespace to deploy package. It will be created if doesn
'
t exist
force:
required: false
default: false
description:
- A flag to indicate to force delete, replace.
registry:
required: false
default:
'
https://api.kpm.sh
'
description:
- The registry url to fetch packages
version:
required: false
default:
'
None
'
description:
- The package version
state:
required: false
choices: [
'
present
'
,
'
absent
'
]
default: present
description:
- present handles checking existence or creating resources,
absent handles deleting resource(s).
requirements:
- kubectl
- kpm
author:
"
Antoine Legrand (ant31_2t@msn.com)
"
"""
EXAMPLES
=
"""
- name: check presence or install ghost
kpm: name=ghost/ghost state=present
- name: check absence or remove rocketchat
kpm: name=ant31/rocketchat state=absent
"""
RETURN
=
"""
"""
def
check_changed
(
result
,
state
=
'
present
'
):
no_change
=
[
"
ok
"
,
'
protected
'
,
'
absent
'
]
for
r
in
result
:
if
r
[
'
status
'
]
not
in
no_change
:
return
True
return
False
def
main
():
module
=
AnsibleModule
(
supports_check_mode
=
True
,
argument_spec
=
dict
(
version
=
dict
(
default
=
None
,
required
=
False
),
state
=
dict
(
default
=
'
present
'
,
choices
=
[
'
present
'
,
'
absent
'
]),
name
=
dict
(
required
=
True
),
force
=
dict
(
required
=
False
,
default
=
False
,
type
=
'
bool
'
),
registry
=
dict
(
required
=
False
,
default
=
"
https://api.kpm.sh
"
),
namespace
=
dict
(
default
=
'
default
'
,
required
=
False
)))
params
=
{
"
version
"
:
module
.
params
.
get
(
"
version
"
),
"
namespace
"
:
module
.
params
.
get
(
'
namespace
'
),
"
endpoint
"
:
module
.
params
.
get
(
'
registry
'
),
"
dry
"
:
module
.
check_mode
,
"
proxy
"
:
None
,
"
fmt
"
:
"
json
"
}
state
=
module
.
params
.
get
(
"
state
"
)
try
:
if
state
==
'
present
'
:
r
=
kpm
.
deploy
.
deploy
(
module
.
params
.
get
(
'
name
'
),
**
params
)
elif
state
==
'
absent
'
:
r
=
kpm
.
deploy
.
delete
(
module
.
params
.
get
(
'
name
'
),
**
params
)
except
Exception
as
e
:
module
.
fail_json
(
msg
=
e
.
message
)
res
=
{}
res
[
'
kpm
'
]
=
r
res
[
'
changed
'
]
=
check_changed
(
r
,
state
)
module
.
exit_json
(
**
res
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
roles/kubernetes-apps/defaults/main.yaml
0 → 100644
+
4
−
0
View file @
cd2847c1
---
kpm_registry
:
"
https://api.kpm.sh"
kpm_namespace
:
"
default"
kpm_packages
:
[]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
roles/kubernetes-apps/tasks/main.yaml
0 → 100644
+
9
−
0
View file @
cd2847c1
-
name
:
manage kubernetes applications
kpm
:
namespace
:
"
{{item.namespace
|
default(kpm_namespace
|
default('default'))}}"
registry
:
"
{{item.registry
|
default(kpm_registry
|
default('https://api.kpm.sh'))}}"
state
:
"
{{item.state
|
default(omit)}}"
version
:
"
{{item.version
|
default(omit)}}"
name
:
"
{{item.name}}"
with_items
:
"
{{kpm_packages}}"
register
:
kpmresults
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment