ahelal / kitchen-ansiblepush

test-kitchen plugin to use ansible in push mode
41 stars 22 forks source link

Dropping the first part of the instance name creates issue in the inventory #16

Closed arielsalvo closed 8 years ago

arielsalvo commented 8 years ago

Hi!

What's the reason behind dropping the first part of the instance name when generating the machine name?

      def machine_name
        return @machine_name if defined? @machine_name
        @machine_name = instance.name.gsub(/[<>]/, '').split("-").drop(1).join("-")
        debug("machine_name=" + @machine_name.to_s)
        @machine_name
      end

I have an issue with the incomplete machine name when I try to use the inventory (it just ignores the test suite) Plus: the way of dropping the first part fails if the suite itself has a dash in it.

> ./test.sh converge default-debian-7
-----> Starting Kitchen (v1.7.2)
-----> Creating <default-debian-7>...
       Digital Ocean instance <13216593> created.
       Waiting for SSH service on 45.55.201.154:22, retrying in 3 seconds
       Waiting for SSH service on 45.55.201.154:22, retrying in 3 seconds
       [SSH] Established
       (ssh ready)

       Finished creating <default-debian-7> (0m36.71s).
-----> Converging <default-debian-7>...
$$$$$$ Running legacy converge for 'Digitalocean' Driver
       Preparing files for transfer
       *************** AnsiblePush install_command ***************
       Ansible push config validated
       Transferring files to <default-debian-7>
       *************** AnsiblePush run ***************

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [debian-7]

TASK [apt_preferences : Remove APT preferences] ********************************

TASK [apt_preferences : Create APT preferences] ********************************

PLAY RECAP *********************************************************************
debian-7                   : ok=1    changed=0    unreachable=0    failed=0

       *************** idempotency test ***************
Using changes callback for V2

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [debian-7]

TASK [apt_preferences : Remove APT preferences] ********************************

TASK [apt_preferences : Create APT preferences] ********************************

PLAY RECAP *********************************************************************
debian-7                   : ok=1    changed=0    unreachable=0    failed=0

       idempotency test [passed]
       *************** AnsiblePush end run *******************
       Finished converging <default-debian-7> (0m9.29s).
-----> Kitchen is finished. (0m46.30s)

Check out the generated inventory below:

> kitchen-ansible-inventory
{
  "all": [
    "debian-7"
  ],
  "_meta": {
    "hostvars": {
      "debian-7": {
        "ansible_ssh_host": "45.55.201.154",
        "ansible_ssh_port": "22",
        "ansible_ssh_private_key_file": "/Users/asalvo/.ssh/id_rsa"
      }
    }
  }
}

Any reason for not using the complete instance name? I think just removing .split("-").drop(1).join("-") would be enough.

What do you think?

Regards! --Ariel

athak commented 8 years ago

Hi, I second preserving the suite-platform original name instead of trying to reduce it to the platform name only. This causes issues with concurrency, especially in CI environments where running multiple tests grouped by platform is impossible with the current machine_name.

Best, Atha

ahelal commented 8 years ago

@athak @arielsalvo

The idea is to use to remove the suite name by default to avoid creating multi entries in your inventory file this will happen if you use mutli suites entry.

How about creating a machine_name in the .kitchen.yml ? if defined will be used instead of the default behaviour.

athak commented 8 years ago

I don't think that would work since it would have to be specified for each combination. How about a use_machine_name flag that preserves the original name when set to to true and is false by default?

ahelal commented 8 years ago

That sounds good. Are you able to make a PR for that ? if not, I am currently busy would not be able to do something about it before two weeks.

athak commented 8 years ago

Will do. Can you check why the 0.3.10 release is missing from the repo? It is on rubygems.org but not here.

ahelal commented 8 years ago

@athak my mistake can you please jump to 0.3.11

athak commented 8 years ago

Done, please see https://github.com/ahelal/kitchen-ansiblepush/pull/17

ahelal commented 8 years ago

@athak released 0.3.11 thank you for your efforts.

athak commented 8 years ago

@ahelal you're most welcome. Thank you for developing this in the first place!