Skip to content

AnsibleRun Support in Composition/XR #172

Open
@ride808

Description

@ride808

What happened?

I can create an AnsibleRun resource without issue and run an inline ansible playbook. However, I'm unable to add the same AnsibleRun resource as a part of a larger crossplane composition/XR. Should it be possible to use AnsibleRun within an XR?

How can we reproduce it?

Creating an AnsibleRun Resources like the following works without issue:

apiVersion: ansible.crossplane.io/v1alpha1
kind: AnsibleRun
metadata:
  name: ansible-example
spec:
  forProvider:
    playbookInline: |
      ---
      - hosts: localhost
        tasks:
          - name: ansibleplaybook-example
            debug:
              msg: Your are running 'ansibleplaybook-example' example
  providerConfigRef:
    name: provider-ansible

When adding the same resource to an XR like below, the other resources (EC2 and SecurityGroup) in the composition are created, but the ansiblerun resource is not created:

apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: admin-server
  labels:
    crossplane.io/xrd: xadmininstances.aws.hades.org
    provider: provider-aws
spec:
  writeConnectionSecretsToNamespace: crossplane-system
  compositeTypeRef:
    apiVersion: hades.org/v1alpha1
    kind: XAdminInstance
  resources:
  - name: securitygroup
    base:
      apiVersion:  ec2.aws.crossplane.io/v1beta1
      kind: SecurityGroup
      spec:
        forProvider:
          region: us-east-1
          vpcId: vpc-0186b862b83f5cd71
          description: Admin server for Environment
          ingress:
            - fromPort: 0
              toPort: 65535
              ipProtocol: tcp
              ipRanges:
                - cidrIp: 10.77.77.20/32
            - fromPort: 22
              toPort: 22
              ipProtocol: tcp
              ipRanges:
                - cidrIp: 10.77.77.10/32
            - fromPort: 22
              toPort: 22
              ipProtocol: tcp
              ipRanges:
                - cidrIp: 166.28.0.0/16
            - fromPort: 443
              toPort: 443
              ipProtocol: tcp
              ipRanges:
                - cidrIp: 0.0.0.0/32
            - fromPort: 8080
              toPort: 8084
              ipProtocol: tcp
              ipRanges:
                - cidrIp: 0.0.0.0/32
            - fromPort: 80
              toPort: 80
              ipProtocol: tcp
              ipRanges:
                - cidrIp: 0.0.0.0/0
        providerConfigRef:
          name: provider-aws
    patches:
      - type: FromCompositeFieldPath
        fromFieldPath: "metadata.name"
        toFieldPath: "spec.forProvider.groupName"
  - name: admin-instance
    base:
      apiVersion:  ec2.aws.crossplane.io/v1alpha1
      kind: Instance
      spec:
        forProvider:
          region: us-east-1
          imageId: ami-02ae903c0b1d9fd12
          instanceType: t3.medium
          keyName: hades-key
          blockDeviceMappings:
          - deviceName: /dev/sdx
            ebs:
              volumeType: gp3
          subnetId: subnet-08d3a539398176845
          securityGroupSelector:
            matchControllerRef: true
          tags:
            - key: Name
              value: somogyi-admin
        providerConfigRef:
          name: provider-aws
    patches:
      - type: FromCompositeFieldPath
        fromFieldPath: "spec.parameters.storageGB"
        toFieldPath: "spec.forProvider.blockDeviceMappings[0].ebs.volumeSize"
  - name: ansibleconfig
    base:
      apiVersion: ansible.crossplane.io/v1alpha1
      kind: AnsibleRun
      spec:
        forProvider:
          playbookInline: |
            ---
            - hosts: localhost
              tasks:
                - name: ansibleplaybook-example
                  debug:
                    msg: Hello world!
        providerConfigRef:
          name: provider-ansible

What environment did it happen in?

Crossplane version: 1.10.1
provider-ansible:v0.4.0
provider-aws:v0.33.0

  • Cloud provider or hardware configuration: AWS
  • Kubernetes version (use kubectl version): 1.21.1
  • Kubernetes distribution (e.g. Tectonic, GKE, OpenShift): RKE2
  • OS (e.g. from /etc/os-release): RHEL 8.7
  • Kernel (e.g. uname -a): Linux X86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions