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

Allow randomness in instance names or use instance IDs #887

Closed
berendt opened this issue Jul 5, 2017 · 7 comments
Closed

Allow randomness in instance names or use instance IDs #887

berendt opened this issue Jul 5, 2017 · 7 comments

Comments

@berendt
Copy link

berendt commented Jul 5, 2017

Issue Type

  • Feature request

Current Behaviour

At the moment it is possible to specify the used OpenStack instance names in the configuration. The problem is that those names are unique. This way it is not possible to run the same configuration multiple times. In my CI I want to use the same configuration to run in parallel to be able to kickoff multiple jobs in parallel and to run Ansible 2.2 and Ansible 2.3 tests in parallel.

Desired Behaviour

It should be possible to use one configuration in parallel.

@retr0h
Copy link
Contributor

retr0h commented Jul 5, 2017

molecule.yml can accept env vars. Just have your CI system use a wrapper script which can generate a random name and set RANDOM_NAME prior to executing molecule.

platforms:
  - name: $RANDOM_NAME
    image: centos:latest

@retr0h retr0h added the question label Jul 5, 2017
@berendt
Copy link
Author

berendt commented Jul 6, 2017

Ah cool, I was not aware of this feature. I think this should work for my use cased. Will test this today.

@berendt
Copy link
Author

berendt commented Jul 6, 2017

Tested this with version 1.25 and the OpenStack driver. But the variable is not replaced, I receive $VARNAME in the instance name.

@retr0h
Copy link
Contributor

retr0h commented Jul 7, 2017

Ah, yeah. Molecule expands the env vars when the config is parsed. However, the Ansible playbook is loading the file off disk. I have an idea. Once I land #894 I'll fix this.

@Lirt
Copy link
Contributor

Lirt commented Mar 6, 2019

I feel like the names should be internally randomized by molecule in first run and remembered (as you already do in file /tmp/molecule/<ROLE>/<SCENARIO>/ansible_inventory.yml) to avoid instance name conflicts when working in teams and simultaneously using CIs.

Using non-deterministic IDs is currently unusable, since on each command the instance name is different and you cannot target already created machine.

My workaround for this is using "$HOSTNAME" in the instance name, but this is not 100% bulletproof I guess.

@decentral1se
Copy link
Contributor

Think this is related to #1573 and #1702.

We need to solve this I think ...

@Frodox
Copy link

Frodox commented Jun 3, 2019

@retr0h what do you mean by

Just have your CI system use a wrapper script which can generate a random name and set RANDOM_NAME prior to executing molecule.

?
I run molecule as

docker run --rm \
    ... \
    molecule \
    molecule test

and several platforms as

---
dependency:
  name: galaxy
driver:
  name: openstack
lint:
  name: yamllint
platforms:
  - name: ${RANDOM_NAME}
    image: "Ubuntu 16.04"
    flavor: "d1.c1r1"
  - name: ${RANDOM_NAME}
    image: "Ubuntu 18.04"
    flavor: "d1.c1r1"
provisioner:
  name: ansible
  lint:
    name: ansible-lint
scenario:
  name: default
verifier:
  name: testinfra
  lint:
    name: flake8

So, where should I inject generation of RANDOM_NAME, since ansible-playbook runs it in parallel / lookup envs only once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants