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

Molecule setup for existing Playbook with multiple roles. #1133

Closed
damianoneill opened this issue Feb 16, 2018 · 14 comments
Closed

Molecule setup for existing Playbook with multiple roles. #1133

damianoneill opened this issue Feb 16, 2018 · 14 comments

Comments

@damianoneill
Copy link

damianoneill commented Feb 16, 2018

Issue Type

  • Feature request

Molecule and Ansible details

ansible --version
ansible 2.4.3.0

molecule --version
molecule, version 2.8.2
  • Molecule installation method: One of source, pip
    pip

  • Ansible installation method: One of source, pip, OS package
    pip

Desired Behaviour

Request for information - Initial setup.

Given a directory structure similar to below. For a playbook with existing roles. How should molecule be initialised. I've looked through the docs / online tutorials and a few videos but dont see any guidance on the approach that should be used.

Apologies if this is covered somewhere else.

$ tree .
.
├── group_vars
│   └── all
├── playbook.yml
└── roles
    ├── cassandra
    │   ├── files
    │   ├── handlers
    │   │   └── main.yml
    │   ├── meta
    │   ├── tasks
    │   │   └── main.yml
    │   ├── templates
    │   └── vars
    ├── common
    │   ├── files
    │   ├── handlers
    │   │   └── main.yml
    │   ├── meta
    │   ├── tasks
    │   │   └── main.yml
    │   ├── templates
    │   └── vars
    └── web
        ├── files
        ├── handlers
        │   └── main.yml
        ├── meta
        ├── tasks
        │   └── main.yml
        ├── templates
        └── vars
@damianoneill
Copy link
Author

To provide some context, in this playbook I'd like to test against a vagrant based, 3 vm cluster with scenarios for both CentOS and Ubuntu. With the common and cassandra roles applied on all nodes and the web role applied on a single node.

@r0ckyte
Copy link

r0ckyte commented Feb 19, 2018

@damianoneill - may try something like this
molecule.yml
playbook

@retr0h
Copy link
Contributor

retr0h commented Feb 19, 2018

@damianoneill
Copy link
Author

damianoneill commented Feb 19, 2018

@r0ckyte thanks I'll look through this later today.

@retr0h I read this when I went through the docs. This statement 'The role initialized with Molecule (baz in this case) would simply reference the dependant roles via it’s playbook.yml or meta dependencies.' implies that an existing role can be initialized. I tried a number of combinations of the tooling but it seemed that you had to create a new role, you couldn't init an existing role. Maybe I was doing something stupid.

mkdir -p monolith-repo/{roles/{bar,baz,foo},library,plugins/filters}
cd monolith-repo/roles

$ molecule init role -r baz
--> Initializing new role baz...
ERROR: The directory baz exists. Cannot create new role.

@damianoneill
Copy link
Author

damianoneill commented Feb 19, 2018

Similar question found when googling "molecule monolith-repo' useful text - #1010 (comment)

@retr0h
Copy link
Contributor

retr0h commented Feb 19, 2018

mkdir -p monolith-repo/{roles/{bar,baz,foo},library,plugins/filters}
cd monolith-repo/roles

Your mkdir is messing you up. If you want to create role foo, don't mkdir the directory first ;)

@damianoneill
Copy link
Author

@retr0h understood, point I'm making is you cant run the init command on an existing role, I was just using your example to demonstrate. I've seen a few examples online for molecule v1 where this functionality seems to exist. Is this no longer supported in v2?

Thanks,
Damian.

@retr0h
Copy link
Contributor

retr0h commented Feb 19, 2018

Sure you can, you jsut need to run the proper command ;)

Check the docs, Initialize an existing role with Molecule.

@damianoneill
Copy link
Author

@retr0h appreciate your patience.

Again I had tried that previously and got an error.

$ ls
bar baz foo
$ molecule init scenario --scenario-name default --role-name baz
ERROR: The role 'baz' not found. Please choose the proper role name. 

Is the init scenario looking for anything other than a directory name?

Thanks,
Damian.

@retr0h
Copy link
Contributor

retr0h commented Feb 19, 2018

You need to be in the proper directory. Molecule verifies you are in the directory you are "initializing".

@retr0h
Copy link
Contributor

retr0h commented Feb 19, 2018

@damianoneill
Copy link
Author

Thankyou @retr0h, honestly that was the only combo I didnt try.

@retr0h
Copy link
Contributor

retr0h commented Feb 19, 2018

Thankyou @retr0h, honestly that was the only combo I didnt try.

My apologies it was confusing. I have updated the README with the screencast, and updated the docs to ensure the developer knows to cd into the role first.

@damianoneill
Copy link
Author

Not at all, the support from yourself and @r0ckyte has been great, thanks.

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

No branches or pull requests

3 participants