ansible-community / molecule-vmware

Molecule VMware Driver
MIT License
14 stars 12 forks source link

remote_user not working #23

Open rgilmiyarov opened 3 years ago

rgilmiyarov commented 3 years ago
SUMMARY
ISSUE TYPE
ANSIBLE VERSION
ansible [core 2.11.2]
  config file = None
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.local/bin/ansible
  python version = 3.8.10 (default, Jun  2 2021, 10:49:15) [GCC 9.4.0]
  jinja version = 2.10.1
  libyaml = True
CONFIGURATION
dependency:
  name: galaxy
driver:
  name: vmware
  vcenter_hostname: vcenter_hostname
  vcenter_username: vcenter_username
  vcenter_password: vcenter_password
  validate_certs: false
  datacenter: datacenter
  esxi_hostname: esxi_hostname
  folder: "/folder"
  vm_username: root
  vm_password: password
  instance_os_type: linux
platforms:
  - name: molecule-test
    template: "rhel_template_vm"
    resource_pool: rpool
    hardware:
      num_cpus: 2
      memory_mb: 4096
    networks:
      - name: VM_168.1.0/24_ID1
        ip: 192.168.1.100
        netmask: 255.255.255.0
        gateway: 192.168.1.1
provisioner:
  name: ansible
verifier:
  name: ansible
lint: |
  set -e
  yamllint .
  ansible-lint
  flake8
OS / ENVIRONMENT
STEPS TO REPRODUCE
- hosts: all
  tasks:
    - debug: var=ansible_user

- hosts: all
  remote_user: ansible
  tasks:
    - debug: var=ansible_user
EXPECTED RESULTS
TASK [debug] *******************************************************************
ok: [molecule-test] => {
    "ansible_user": "root"
}

TASK [debug] *******************************************************************
ok: [molecule-test] => {
    "ansible_user": "ansible"
}
ACTUAL RESULTS
TASK [debug] *******************************************************************
ok: [molecule-test] => {
    "ansible_user": "root"
}

TASK [debug] *******************************************************************
ok: [molecule-test] => {
    "ansible_user": "root"
}
sky-joker commented 3 years ago

Thanks, @rgilmiyarov for reporting this issue.

The issue isn't a bug for the molecule.
Please see: https://docs.ansible.com/ansible/2.9/user_guide/playbooks_variables.html?highlight=ansible_user#variable-precedence-where-should-i-put-a-variable

If you want to overwrite the ansible_user variable, for example, please use the vars directive, not remote_user.

You can also override as a normal variable in a play:

- hosts: all
  vars:
    ansible_user: lola
  tasks:
    - command: I'll connect as lola!

Does this answer your question?