Skip to content

ansible 2.0 no longer looks for ansible.cfg in playbook directory #14016

@oppianmatt

Description

@oppianmatt
Issue Type:

Bug Report

Ansible Version:
~ # ansible-playbook --version
ansible-playbook 2.0.0.2
  config file =
  configured module search path = Default w/o overrides
~ # ansible --version
ansible 2.0.0.2
  config file =
  configured module search path = Default w/o overrides
Ansible Configuration:

ansible.cfg

[defaults]
hostfile = ./hosts
nocows = 1
ansible_managed = Ansible managed, do not edit directly: {file} by {uid} on {host}

[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o ForwardAgent=yes
pipelining=True

Environment:

Ubuntu 12.04.5 LTS
Ubuntu 12.04.5 LTS

Summary:

Database copy script that has been running pre ansible 2.0 has started failing.

Steps To Reproduce:

Upgrade to ansible 2.0. Difference is that ansible 2.0 isn't picking up the ansible.cfg file that's in the same directory as the playbook and so uses default options for ssh. Don't know why the defaults for ssh fail but the fix is the cd into the directory first. Pre ansible 2.0 looked for config in the current play directory.

Expected Results:
# su copy_database -c '/usr/local/bin/ansible-playbook -f 1 /mnt/ssd/django/pitchup_prod/ansible/playbooks/pitchup/copy_database.yaml -i /
mnt/ssd/django/pitchup_prod/ansible/playbooks/pitchup/inventory/dev -vvvv'
Using /mnt/ssd/django/pitchup_prod/ansible/playbooks/pitchup/ansible.cfg as config file
[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and make sure become_method is 'sudo' (default). This feature will be removed in a future
release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
Loaded callback default of type stdout, v2.0
1 plays in /mnt/ssd/django/pitchup_prod/ansible/playbooks/pitchup/copy_database.yaml

PLAY [copy database] ***********************************************************


TASK [setup] *******************************************************************
<devpitchup.pitchup.com> ESTABLISH SSH CONNECTION FOR USER: None
<devpitchup.pitchup.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=30m -o ForwardAgent=yes -o KbdInteractiveAuthentication=no -o PreferredAuthentica
tions=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/copy_database/.ansible/cp/ansible-ssh-%h-%
p-%r devpitchup.pitchup.com '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-fgoaqjgnoouwszjfrcebkeazxrevfxfg; LANG=en_GB.UTF-8 LC
_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 /usr/bin/python'"'"'"'"'"'"'"'"''"'"''
ok: [devpitchup.pitchup.com]

...
Actual Results:
~ # su copy_database -c '/usr/local/bin/ansible-playbook -f 1 /mnt/ssd/django/pitchup_prod/ansible/playbooks/pitchup/copy_database.yaml -i /mnt/ssd/django/pitchup_prod/
ansible/playbooks/pitchup/inventory/dev -vvvv'
No config file found; using defaults
[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and make sure become_method is 'sudo' (default). This feature will be removed in a future
release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
Loaded callback default of type stdout, v2.0
1 plays in /mnt/ssd/django/pitchup_prod/ansible/playbooks/pitchup/copy_database.yaml

PLAY [copy database] ***********************************************************

TASK [setup] *******************************************************************
<devpitchup.pitchup.com> ESTABLISH SSH CONNECTION FOR USER: None
<devpitchup.pitchup.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mi
c,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/copy_database/.ansible/cp/ansible-ssh-%h-%p-%r -tt devpitchup.
pitchup.com '( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1453287563.5-209169123401042 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1453287563.5
-209169123401042 )" )'
<devpitchup.pitchup.com> PUT /tmp/tmprYQf0w TO       ^/setup
<devpitchup.pitchup.com> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-w
ith-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/copy_database/.ansible/cp/ansible-ssh-%h-%p-%r '[devpitc
hup.pitchup.com]'
fatal: [devpitchup.pitchup.com]: FAILED! => {"failed": true, "msg": "ERROR! failed to transfer file to       ^/setup:\nsftp> put /tmp/tmprYQf0w '      ^/setup'\nUploadi
ng /tmp/tmprYQf0w to /home/copy_database/      ^/setup\n\nOpenSSH_5.9p1 Debian-5ubuntu1.7, OpenSSL 1.0.1 14 Mar 2012\ndebug1: Reading configuration data /etc/ssh/ssh_co
nfig\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client
_hello_exchange: master version 4\r\ndebug3: mux_client_request_forwards: requesting forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\nd
ebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 25855\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: m
ux_client_request_session: master session id: 2\r\ndebug2: Remote version: 3\r\ndebug2: Server supports extension \"posix-rename@openssh.com\" revision 1\r\ndebug2: Ser
ver supports extension \"statvfs@openssh.com\" revision 2\r\ndebug2: Server supports extension \"fstatvfs@openssh.com\" revision 2\r\ndebug2: Server supports extension
\"hardlink@openssh.com\" revision 1\r\ndebug3: Sent message fd 3 T:16 I:32698\r\ndebug3: SSH_FXP_REALPATH . -> /home/copy_database\r\ndebug3: Looking up /tmp/tmprYQf0w\
r\ndebug3: Sent message fd 3 T:17 I:32699\r\ndebug3: Received stat reply T:101 I:32699\r\ndebug1: Couldn't stat remote file: No such file or directory\r\ndebug3: Sent m
essage SSH2_FXP_OPEN I:32700 P:/home/copy_database/      ^/setup\r\nremote open(\"/home/copy_database/      ^/setup\"): No such file or directory\r\ndebug3: mux_client_
read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n"}

NO MORE HOSTS LEFT *************************************************************

PLAY RECAP *********************************************************************
devpitchup.pitchup.com     : ok=0    changed=0    unreachable=0    failed=1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions