AnsibleRun represents a set of Ansible Playbooks.
Type
CRD
Group
ansible.crossplane.io
Version
v1alpha1
apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
A AnsibleRunSpec defines the desired state of a AnsibleRun.
AnsibleRunParameters are the configurable fields of a AnsibleRun.
The Inventories of this AnsibleRun.
Env is a reference to an environment variable that contains credentials that must be used to connect to the provider.
Fs is a reference to a filesystem location that contains credentials that must be used to connect to the provider.
THIS IS A BETA FIELD. It is on by default but can be opted out through a Crossplane feature flag. ManagementPolicies specify the array of actions Crossplane is allowed to take on the managed and external resources. This field is planned to replace the DeletionPolicy field in a future release. Currently, both could be set independently and non-default values would be honored if the feature flag is enabled. If both are custom, the DeletionPolicy field will be ignored. See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md
ProviderConfigReference specifies how the provider that will be used to create, observe, update, and delete this managed resource should be configured.
Policies for referencing.
PublishConnectionDetailsTo specifies the connection secret config which contains a name, metadata and a reference to secret store config to which any connection details for this managed resource should be written. Connection details frequently include the endpoint, username, and password required to connect to the managed resource.
WriteConnectionSecretToReference specifies the namespace and name of a Secret to which any connection details for this managed resource should be written. Connection details frequently include the endpoint, username, and password required to connect to the managed resource. This field is planned to be replaced in a future release in favor of PublishConnectionDetailsTo. Currently, both could be set independently and connection details would be published to both without affecting each other.
A AnsibleRunStatus represents the observed state of a AnsibleRun.
Conditions of the resource.
gcpbucket
apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
metadata:
annotations:
ansible.crossplane.io/runPolicy: ObserveAndDelete
name: gcpbucket
spec:
forProvider:
playbookInline: |
---
- hosts: localhost
pre_tasks:
- name: Install requests python package on version 2.28.1
ansible.builtin.pip:
name: requests==2.28.1
extra_args: --user
- name: Install google-auth python package on version 2.12.0
ansible.builtin.pip:
name: google-auth==2.12.0
extra_args: --user
tasks:
- name: create a gcp bucket
google.cloud.gcp_storage_bucket:
# please make sure that name is unique
name: ansible-storage-module
project: test-project
auth_kind: serviceaccount
service_account_file: gcp-credentials.json
state: present
when: ansible_provider_meta.gcpbucket.state == 'present'
providerConfigRef:
name: default
secret-inventory-remote-debug
apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
metadata:
name: secret-inventory-remote-debug
spec:
forProvider:
inventories:
- secretRef:
key: hosts
name: inventory
namespace: crossplane-system
source: Secret
playbookInline: |
---
- hosts: all
tasks:
- name: ansibleplaybook-simple
debug:
msg: Your are running 'ansibleplaybook-simple' example
gcpdisk
apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
metadata:
annotations:
ansible.crossplane.io/runPolicy: CheckWhenObserve
name: gcpdisk
spec:
forProvider:
roles:
- name: ansible_provider.gcpdisk_role
src: https://github.com/multicloudlab/crossplane-ansible-provider-sample.git
vars:
project:
disk:
key: 718BDCC469891
size: 20
zone: europe-west1-b
id: test_project
providerConfigRef:
name: gcpconfig
executable-inventory
apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
metadata:
name: executable-inventory
spec:
forProvider:
executableInventory: true
inventoryInline: >
#!/usr/bin/env python3
import json
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--list", action="store_true", help="Show JSON of all managed hosts")
parser.add_argument("--host", help="Display vars related to the host")
args = parser.parse_args()
if args.list:
print(json.dumps({"all": {"hosts": ["localhost"]}}, indent=4))
elif args.host:
print(json.dumps({"ansible_connection": "local"}, indent=4))
playbookInline: |
---
- hosts: all
tasks:
- name: ansibleplaybook-simple
debug:
msg: Your are running 'ansibleplaybook-simple' example
inline-inventory-remote-debug
apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
metadata:
name: inline-inventory-remote-debug
spec:
forProvider:
inventoryInline: |
127.14.1.2
playbookInline: |
---
- hosts: all
tasks:
- name: ansibleplaybook-simple
debug:
msg: Your are running 'ansibleplaybook-simple' example
© 2022 Upbound, Inc.
Discover the building blocksfor your internal cloud platform.