Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eh_instance module for creating/deleting ElasticHosts instances #55537

Open
wants to merge 31 commits into
base: devel
from

Conversation

Projects
None yet
3 participants
@nickyfow
Copy link

commented Apr 18, 2019

SUMMARY

Add eh_instance module, which allows creating/deleting ElasticHosts instances.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

eh_instance

ADDITIONAL INFORMATION

Tested the module by setting auth (redacted):

export EHUSER=123-123-123
export EHAUTH=123-123-123
ansible-playbook main.yml

where main.yml is:

---
- name: Create instance
  hosts: localhost
  tasks:
  - name: Create instance
    eh_instance:
      name: machine19
    register: instance_info
  - debug:
      var: instance_info
  - add_host:
      hostname: instance
      ansible_host: "{{ instance_info.instance.ip }}"
      ansible_user: root

- name: Work on instance
  hosts: instance
  gather_facts: no
  tasks:
  - wait_for_connection:
      timeout: 20
  - setup:
  - command: uname -a
    register: p
  - debug:
      var: p

- name: Destroy instance
  hosts: localhost
  tasks:
  - debug:
      var: instance_info
  - name: Destroy instance
    eh_instance:
      uuid: "{{ instance_info.instance.uuid }}"
      state: absent
      force: true
    register: p
  - debug:
      var: p

which gave

$ ansible-playbook main.yml 
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit
localhost does not match 'all'


PLAY [Create instance] ****************************************************************************

TASK [Gathering Facts] ****************************************************************************
ok: [localhost]

TASK [Create instance] ****************************************************************************
changed: [localhost]

TASK [debug] **************************************************************************************
ok: [localhost] => {
    "instance_info": {
        "changed": true,
        "failed": false,
        "instance": {
            "cpu": 500,
            "disk": "f0f267db-9513-4125-a1da-6d7bc057400c",
            "ip": "100.100.100.100",
            "name": "machine19",
            "persistent": "true",
            "status": "active",
            "type": "container",
            "uuid": "87b05a23-db5d-4b95-8901-ad23f3b928b6"
        }
    }
}

TASK [add_host] ***********************************************************************************
changed: [localhost]

PLAY [Work on instance] ***************************************************************************

TASK [wait_for_connection] ************************************************************************
ok: [instance]

TASK [setup] **************************************************************************************
ok: [instance]

TASK [command] ************************************************************************************
changed: [instance]

TASK [debug] **************************************************************************************
ok: [instance] => {
    "p": {
        "changed": true,
        "cmd": [
            "uname",
            "-a"
        ],
        "delta": "0:00:00.002426",
        "end": "2019-04-18 23:31:09.544863",
        "failed": false,
        "rc": 0,
        "start": "2019-04-18 23:31:09.542437",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "Linux debian 4.14.65-elastic #1 SMP Tue Aug 21 06:18:28 UTC 2018 x86_64 GNU/Linux",
        "stdout_lines": [
            "Linux debian 4.14.65-elastic #1 SMP Tue Aug 21 06:18:28 UTC 2018 x86_64 GNU/Linux"
        ]
    }
}

PLAY [Destroy instance] ***************************************************************************

TASK [Gathering Facts] ****************************************************************************
ok: [localhost]
TASK [debug] **************************************************************************************
ok: [localhost] => {
    "instance_info": {
        "changed": true,
        "failed": false,
        "instance": {
            "cpu": 500,
            "disk": "f0f267db-9513-4125-a1da-6d7bc057400c",
            "ip": "100.100.100.100",
            "name": "machine19",
            "persistent": "true",
            "status": "active",
            "type": "container",
            "uuid": "87b05a23-db5d-4b95-8901-ad23f3b928b6"
        }
    }
}

TASK [Destroy instance] ***************************************************************************
changed: [localhost]

TASK [debug] **************************************************************************************
ok: [localhost] => {
    "p": {
        "changed": true,
        "failed": false
    }
}

PLAY RECAP ****************************************************************************************
instance                   : ok=4    changed=1    unreachable=0    failed=0   
localhost                  : ok=8    changed=3    unreachable=0    failed=0   
@nickyfow

This comment has been minimized.

Copy link
Author

commented Apr 18, 2019

Working on resolving the two sanity test failures

@ansibot ansibot added the stale_ci label Apr 27, 2019

Konrad Pisarczyk added some commits May 9, 2019

Konrad Pisarczyk
Konrad Pisarczyk

Konrad Pisarczyk and others added some commits May 9, 2019

Konrad Pisarczyk
@mattclay

This comment has been minimized.

Copy link
Member

commented May 23, 2019

bot_status

@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 23, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/cloud/elastichosts/eh_instance.py:253:9: E122 continuation line missing indentation or outdented

The test ansible-test sanity --test validate-modules [explain] failed with 2 errors:

lib/ansible/modules/cloud/elastichosts/eh_instance.py:0:0: E324 Argument 'ssh_key' in argument_spec defines default as (None) but documentation defines default as ('None')
lib/ansible/modules/cloud/elastichosts/eh_instance.py:0:0: E324 Argument 'type' in argument_spec defines default as ('container') but documentation defines default as ('present')

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 23, 2019

Components

lib/ansible/modules/cloud/elastichosts/init.py
support: community
maintainers:

lib/ansible/modules/cloud/elastichosts/eh_instance.py
support: community
maintainers:

Metadata

waiting_on: nickyfow
changes_requested_by: null
needs_info: False
needs_revision: True
needs_rebase: False
merge_commits: []
too many files or commits: False
mergeable_state: unstable
shippable_status: failure
maintainer_shipits (module maintainers): False
community_shipits (namespace maintainers): False
ansible_shipits (core team members): False
shipit_actors (maintainer or core team member): None
shipit_actors_other:
automerge: automerge shipit test failed

click here for bot help

@ansibot ansibot added the stale_ci label May 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.