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

Delegated driver not generating inventory file as expected #2931

Closed
jodybro opened this issue Oct 30, 2020 · 1 comment · Fixed by #3121
Closed

Delegated driver not generating inventory file as expected #2931

jodybro opened this issue Oct 30, 2020 · 1 comment · Fixed by #3121
Labels

Comments

@jodybro
Copy link

jodybro commented Oct 30, 2020

Issue Type

  • Bug report

Molecule and Ansible details

ansible --version && molecule --version

ansible 2.9.9
molecule 3.1.4

Molecule installation method (one of):

  • source
  • pip

pip

Ansible installation method (one of):

  • source
  • pip
  • OS package

pip

Detail any linters or test runners used:

Desired Behavior

Instance created by the create.yml playbook should then have its details placed in the ephemeral inventory file (ip, id, port, user)

Actual Behaviour

Using the delegated driver for a bit of testing. Instance(s) are created in ec2.
Instance creation works fine and I end up with the details from the instance in my instance_conf (ip, instanceid, port, user).

But when molecule generates the ephemeral inventory file...none of these values are placed.

instance_config.yml

- {address: $ip, instance: $id, port: '22', user: $user}

molecule.yml

---
driver:
  name: delegated
  options:
    managed: True
platforms:
  - name: molecule-builder
    instance_type: t3.medium
    vpc_subnet_id: $subnet
    group_id: $sg
    groups:
      - molecule-builder
provisioner:
  name: ansible
  config_options:
    defaults:
      callback_whitelist: profile_tasks, timer, yaml
    ssh_connection:
      pipelining: true
      host_key_checking: no
verifier:
  name: ansible
lint: |
  set -e
  ansible-lint
scenario:
  name: default
  test_sequence:
    - destroy
    - create
    - converge

ansible_inventory.yml

---
all:
  hosts:
    molecule-builder: &id001 {}
  vars: &id002
    molecule_ephemeral_directory: '{{ lookup(''env'', ''MOLECULE_EPHEMERAL_DIRECTORY'')
      }}'
    molecule_file: '{{ lookup(''env'', ''MOLECULE_FILE'') }}'
    molecule_instance_config: '{{ lookup(''env'', ''MOLECULE_INSTANCE_CONFIG'') }}'
    molecule_no_log: '{{ lookup(''env'', ''MOLECULE_NO_LOG'') or not molecule_yml.provisioner.log|default(False)
      | bool }}'
    molecule_scenario_directory: '{{ lookup(''env'', ''MOLECULE_SCENARIO_DIRECTORY'')
      }}'
    molecule_yml: '{{ lookup(''file'', molecule_file) | from_yaml }}'
instance:
  hosts:
    molecule-builder: *id001
  vars: *id002
ungrouped:
  vars: {}
@jodybro jodybro added the bug label Oct 30, 2020
@jodybro
Copy link
Author

jodybro commented Oct 30, 2020

Found #1292 and made some adjustments:

  • Generating an ssh_config file per host (only 1 right now) and placing that in /tmp/ssh_config
  • Passing in some options to my molecule.yml to try and use this config file

Right now I'm not seeing any of my changes take affect though.

Current molecule.yml

---
driver:
  name: delegated
  options:
    managed: True
    login_cmd_template: 'ssh {instance} -F /tmp/ssh_config'
    ansible_connection_options:
      connection: ssh
      ansible_ssh_common_args: -F /tmp/ssh_config
platforms:
  - name: molecule-builder
    instance_type: t3.medium
    vpc_subnet_id: $subnet
    group_id: $sg
    groups:
      - instance
provisioner:
  name: ansible
  config_options:
    defaults:
      callback_whitelist: profile_tasks, timer, yaml
    ssh_connection:
      pipelining: true
      host_key_checking: no
verifier:
  name: ansible
lint: |
  set -e
  ansible-lint
scenario:
  name: default
  test_sequence:
    - destroy
    - create
    - converge

Debugged the ansible ssh command and I see:

<molecule-builder> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/Users/$user/.ansible/cp/%h-%p-%r molecule-builder '/bin/sh -c '"'"'/usr/bin/python && sleep 0'"'"''

So the common args dont seem to be getting passed into here.
Ive confirmed that this generated ssh_config works by doing

ssh ${molecule_builder_instance_ip} -F /tmp/ssh_config

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

Successfully merging a pull request may close this issue.

1 participant