Skip to content

Replace exasol.ds.sandbox.lib.ansible by ansible-runner-wrapper #504

@ckunki

Description

@ckunki

This ticket depends on the first release of ansible-runner-wrapper being available on pypi.

Note:

  • Currently, dss_docker/create_image.py adds extra_var docker_container to the Ansible playbook.
  • The variable is only used in playbooks used by dss_docker/create_image.py but should remain in the extra_vars as some playbooks depend on this variable
  • Other than the former implementation of AnsibleAccess in the AI Lab, dss_docker/create_image.py does not need to inspect extra_vars.
  • test/ansible/ansible_sample_playbook.yml contains a reference to the fictional ansible variable test_docker_container but the playbook is never actually evaluated, otherwise ansible could report an error.

Required changes, as ARW differs from former implementation in ai-lab:

  • run_install_dependencies should return a plain dict instead of AnsibleFacts.
  • In _install_dependencies() in file dss_docker/create_image.py use
    host = ansible.InventoryHost(self.container_name)
    access = ansible.Access(retrieve_facts_from=host.host_name)
    fact_dict = run_install_dependencies(
        access,
        configuration=self._ansible_config(),
        host_infos=(host,),
        # ...
    )
    return ansible.Facts(fact_dict, prefixes=["dss_facts"])
  • Remove the files in ai-lab/exasol/ds/sandbox/lib/ansible/
  • Update logging exasol.ds.sandbox.lib.logging.get_status_logger()
    def get_status_logger(log_type: LogType) -> logging.Logger:
        prefix = "exasol." if log_type == LogType.ANSIBLE else "ai-lab-"
        return logging.getLogger(f"{prefix}{log_type.value}")

Hosts

AI Lab's old implementation supported generating an Ansible inventory on the fly. ARW does not support this anymore.

  • File ec2_playbook.yml contains hosts: ec2 which probably matches all hosts with AWS PublicDnsName starting with ec2.
  • This only works if there is an inventory file containing the full public DNS name and the name of the file containing the private key, see Ansible docs on Patterns.

Out of scope

Metadata

Metadata

Assignees

Labels

refactoringCode improvement without behavior change

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions