I see a similar issue probably 1/10 times I run a playbook I'm developing.

I am using wait_for after changing sshd listening port

- hosts: staging
>   tasks:
>     - name: Wait for ssh access on new port
>       wait_for: delay=20 connect_timeout=30 host="{{ ansible_ssh_host }}" 
> port="{{ ansible_ssh_port }}"


 And here is the error I get (I've substituted the actual port with <PORT>, 
and my username with <USER>):

GATHERING FACTS 
> *************************************************************** 
> <162.209.100.204> ESTABLISH CONNECTION FOR USER: <USER>
> <162.209.100.204> REMOTE_MODULE setup
> <162.209.100.204> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o 
> ControlPersist=60s -o 
> ControlPath="/Users/brian/.ansible/cp/ansible-ssh-%h-%p-%r" -o 
> StrictHostKeyChecking=no -o Port=<PORT> -o KbdInteractiveAuthentication=no 
> -o 
> PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
> -o PasswordAuthentication=no -o User=<USER> -o ConnectTimeout=300 
> 162.209.100.204 /bin/sh -c 'mkdir -p 
> $HOME/.ansible/tmp/ansible-tmp-1432149978.13-279657059089785 && chmod a+rx 
> $HOME/.ansible/tmp/ansible-tmp-1432149978.13-279657059089785 && echo 
> $HOME/.ansible/tmp/ansible-tmp-1432149978.13-279657059089785'
> fatal: [162.209.100.204] => SSH Error: ssh: connect to host 
> 162.209.100.204 port <PORT>: Connection refused
>     while connecting to 162.209.100.204:<PORT>


This probably doesn't have anything to do with the rax module. My playbook 
does the following:


   1. Provision rackspace servers with the rax module
   2. Apply a common role that as its last step reconfigures sshd to listen 
   on a nonstandard port and only allow login by <USER>
   3. Adds hosts to a new in-memory group (staging) with updated 
   ansible_ssh_user and ansible_ssh_port
   4. Runs the wait_for play above against these hosts

The error happens when it gathers facts for the wait_for play.

Any help would be much appreciated!
 
 
On Thursday, March 20, 2014 at 11:42:51 AM UTC-5, Jimmy Prescott wrote:
>
> Hello,
>
> Searched around before posting this but I was unable to find anything 
> useful. 
>
> Anyway I am using the rax module to provision a server in the Rackspace 
> Cloud using pyrax etc. The problem is that SOMETIMES the play will fail 
> with a connection refused error.:
>
> PLAY [Wait for port 22 to be ready] 
> *******************************************
>
> TASK: [wait_for port=22 delay=20] 
> *********************************************
> fatal: [testing6] => {'msg': 'FAILED: [Errno 111] Connection refused', 
> 'failed': True}
>
> FATAL: all hosts have already failed -- aborting
>
> I tried adding the wait_for with a delay of 20 but maybe I am doing it 
> wrong. Here is what my play looks like up to the point of failure:
>
> ---
> - name: testing rackspace cloud
>   hosts: localhost
>   tasks:
>     - name: Provision the cloud server
>       local_action:
>         module: rax
>         name: "testing"
>         flavor: "performance1-1"
>         image: "centos-65"
>         count: "1"
>         group: "web"
>         wait: yes
>       register: rax
>
>     - name: Add servers to 'raxhosts' group
>       local_action:
>         module: add_host
>         hostname: "{{ item.name }}"
>         ansible_ssh_host: "{{ item.rax_accessipv4 }}"
>         ansible_ssh_pass: "{{ item.rax_adminpass }}"
>         ansible_ssh_user: root
>         groupname: raxhosts
>       with_items: rax.success
>       when: rax.action == 'create'
>
> - name: Wait for port 22 to be ready
>   hosts: raxhosts
>   gather_facts: False
>   tasks:
>     - wait_for: port=22 delay=20
>
> Any help on this is appreciated. The issue is intermittent sometimes it 
> will run 10 times in a row then fail a few time then work again.
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8ef9e73b-7943-42f9-a8d4-22c7e4f381d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to