Skip to content

wttech/aemc-ansible

Repository files navigation

AEM Compose Logo WTT Logo

Last Release Version Ansible Galaxy Apache License, Version 2.0, January 2004

AEM Compose - Ansible Collection

Provides modules and roles built on top of AEM Compose CLI to provision AEM instances to desired state. Configuration changes are applied idempotently in the Ansible spirit to reduce execution time making the tool effective in practice. Published in Ansible Galaxy.

Example integrations

  1. Packer - good starting point for baking AWS EC2 image using Ansible and AEM Compose Ansible modules
  2. Local - development & testing sandbox for AEM Compose CLI and Ansible Modules which runs Ansible locally/natively
  3. Have an idea for the next one? Want to help? At least raise an issue :)

Example configuration

  1. Vars

    All configuration options available for AEM Compose CLI are also supported in Ansible. There are two ways to define configuration.

    The first way is nesting config values under aem_config_dict Ansible variable defined anywhere e.g in the playbook or custom role (according to own preferences). This special variable is passed to all AEM Compose modules automatically for the sake of simplicity.

    aem_config_dict: 
      instance:
     
      config:
        local_author:
          http_url: http://127.0.0.1:4502
          user: admin
          password: admin
          run_modes: [ local ]
          # ...
        local_publish:
          # ...
    
      package:
        snapshot_patterns: [ "**/*-SNAPSHOT.zip" ]
        snapshot_deploy_skipping: true
    
    # ...

    This approach is used in local example.

    The second way is templating configuration file (aem.yml). The path of the templated file need to be defined in aem_config_file Ansible variable to be automatically passed to AEM Compose CLI. This approach is used in default instance role

  2. Playbook:

    For better flexibility, it is recommended to create your own instance role by copying the default instance role and then adapting it for a project-specific use case. The tasks below are just showcasing meaningful features of AEM Compose Ansible modules.

    - name: create instances
      wttech.aem.instance:
        command: create
    
    - name: turn on instances
      wttech.aem.instance:
        command: up
    
    - name: configure replication agent
      wttech.aem.repl_agent:
        command: setup
        instance_id: local_author
        location: author
        name: publish
        props:
          enabled: true
          transportUri: "{{ aem.instance.config.local_publish.http_url }}/bin/receive?sling:authRequestLogin=1"
          transportUser: "{{ aem.instance.config.local_publish.user }}"
          transportPassword: "{{ aem.instance.config.local_publish.password }}"
          userId: "{{ aem.instance.config.local_publish.user }}"
    
    - name: setup Crypto Support
      wttech.aem.crypto:
        command: setup
    
    - name: deploy APM package
      wttech.aem.pkg:
        command: deploy
        url: https://github.com/wttech/APM/releases/download/apm-5.5.1/apm-all-5.5.1.zip
    
    - name: read some node
      wttech.aem.repo_node:
        command: read
        instance_id: local_author
        path: /content/cq:tags/experience-fragments
      register: res
    
    - name: print node creation time
      debug:
        msg: "Node '/content/cq:tags/experience-fragments' was created at '{{ res.data.node.properties['jcr:created'] }}'"
    
    - name: save some node
      wttech.aem.repo_node:
        command: save
        instance_id: local_author
        path: /content/foo
        props:
          foo: bar3
    
    - name: read some bundle
      wttech.aem.osgi_bundle:
        command: read
        instance_id: local_author
        symbolic_name: com.day.cq.wcm.cq-wcm-core
      register: res
    
    - name: print read bundle ID
      debug:
        msg: "Bundle 'com.day.cq.wcm.cq-wcm-core' has ID '{{ res.data.bundle.details.id }}'"
    
    - name: enable CRX DE
      wttech.aem.osgi_config:
        command: save
        pid: org.apache.sling.jcr.davex.impl.servlets.SlingDavExServlet
        props:
          alias: /crx/server

    Consider reviewing playbooks used in tests in local example for more example usages.

Contributing

Issues reported or pull requests created will be very appreciated.

  1. Fork plugin source code using a dedicated GitHub button.
  2. See development guide
  3. Do code changes on a feature branch created from main branch.
  4. Create a pull request with a base of main branch.

License

AEM Compose is licensed under the Apache License, Version 2.0 (the "License")