Skip to content

Commit

Permalink
Merge pull request #146 from fahedouch/refacto-ansible-examples
Browse files Browse the repository at this point in the history
refacto ansible examples
  • Loading branch information
fahedouch authored Dec 6, 2022
2 parents 2b6fbb7 + 0b62b03 commit 0346e4e
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 14 deletions.
5 changes: 0 additions & 5 deletions apis/v1alpha1/ansibleRun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ type AnsibleRunParameters struct {

// Inventory required to configure ansible inventory.
type Inventory struct {

// Filename to which these inventory
// should be written.
Filename string `json:"filename"`

// Source of the inventory.
// +kubebuilder:validation:Enum=None;Secret;InjectedIdentity;Environment;Filesystem
Source xpv1.CredentialsSource `json:"source"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
metadata:
annotations:
ansible.crossplane.io/runPolicy: ObserveAndDelete
name: remote-debug
name: inline-inventory-remote-debug
spec:
forProvider:
inventoryInline: |
Expand Down
31 changes: 31 additions & 0 deletions examples/ansible/inventory/ansibleRun-inventory-from-secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v1
kind: Secret
metadata:
namespace: crossplane-system
name: inventory
type: Opaque
data:
hosts: QkFTRTY0RU5DT0RFRF9QUk9WSURFUl9DUkVEUw==
---
apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
metadata:
name: secret-inventory-remote-debug
spec:
forProvider:
inventories:
- source: Secret
secretRef:
namespace: crossplane-system
name: inventory
key: hosts
# AnsibleRun default to using a remote source.
# For simple cases you can use an inline source to specify the content of
# playbook.yaml as opaque, inline yaml.
playbookInline: |
---
- hosts: all
tasks:
- name: ansibleplaybook-simple
debug:
msg: Your are running 'ansibleplaybook-simple' example
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ metadata:
name: gcp-credentials
type: Opaque
data:
credentials: BASE64ENCODED_PROVIDER_CREDS
credentials: QkFTRTY0RU5DT0RFRF9QUk9WSURFUl9DUkVEUw==
---
apiVersion: ansible.crossplane.io/v1alpha1
kind: ProviderConfig
Expand Down
49 changes: 49 additions & 0 deletions examples/ansible/runPolicy/ansibleRun-checkWhenObserve-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
metadata:
annotations:
ansible.crossplane.io/runPolicy: CheckWhenObserve
name: gcpdisk
spec:
forProvider:
# AnsibleRun default to using a remote source
# For simple cases you can use an inline source to specify the content of
# playbook.yaml as opaque, inline yaml.
roles:
- name: ansible_provider.gcpdisk_role
src: https://github.com/multicloudlab/crossplane-ansible-provider-sample.git
vars:
project:
disk:
size: 20
key: 718BDCC469891
zone: europe-west1-b
id: test_project
providerConfigRef:
name: gcpconfig
---
apiVersion: v1
kind: Secret
metadata:
namespace: crossplane-system
name: gcp-credentials
type: Opaque
data:
credentials: QkFTRTY0RU5DT0RFRF9QUk9WSURFUl9DUkVEUw==
---
apiVersion: ansible.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: gcpconfig
spec:
# Note that unlike most provider configs this one supports an array of
# credentials. This is because each Ansible playbook uses a single
# Crossplane provider config, but could use multiple providers each
# with their own credentials.
credentials:
- filename: gcp-credentials.json
source: Secret
secretRef:
namespace: crossplane-system
name: gcp-credentials
key: credentials
5 changes: 0 additions & 5 deletions package/crds/ansible.crossplane.io_ansibleruns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ spec:
required:
- name
type: object
filename:
description: Filename to which these inventory should be
written.
type: string
fs:
description: Fs is a reference to a filesystem location
that contains credentials that must be used to connect
Expand Down Expand Up @@ -112,7 +108,6 @@ spec:
- Filesystem
type: string
required:
- filename
- source
type: object
type: array
Expand Down

0 comments on commit 0346e4e

Please sign in to comment.