Sorry, pressed send inadvertently there... -----Original Message----- From: william.doss...@gmail.com <william.doss...@gmail.com> Sent: Monday, July 8, 2019 10:09 AM To: ansible-project@googlegroups.com Subject: RE: [ansible-project] using different remote_user until success
Hi Brian, this seemed like a good way to do it, but I haven't been able to make it work - I haven't done much logic in my plays... mostly just point and shoot tasks. --- - hosts: test gather_facts: false tasks: - name: try users remote_user: "{{ item }}" ping: ignore_unreachable: true failed_when: false with_items: - centos - root - ec2-user When I run this, it loops 3 times, and at the start of each I get... <xxx.xxx.xxx.xxx> ESTABLISH SSH CONNECTION FOR USER: centos failed: [xxx.xxx.xxx.xxx] (item=centos) => { "ansible_loop_var": "item", "item": "centos", < xxx.xxx.xxx.xxx > ESTABLISH SSH CONNECTION FOR USER: centos failed: [xxx.xxx.xxx.xxx] (item=root) => { "ansible_loop_var": "item", "item": "root", "msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).", "unreachable": true < xxx.xxx.xxx.xxx > ESTABLISH SSH CONNECTION FOR USER: centos failed: [xxx.xxx.xxx.xxx] (item=ec2-user) => { "ansible_loop_var": "item", "item": "ec2-user", "msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).", "unreachable": true } So the item is changing, but it seems that you can only set remote_user once? I assume remote_user is what I should be using in the playbook? Ansible_user in the config file and remote_user in the playbook right? This seems like great solution if I could get it to work. Any advice would be hugely appreciated at this point. Regards Bill -----Original Message----- From: ansible-project@googlegroups.com <ansible-project@googlegroups.com> On Behalf Of Brian Coca Sent: Friday, July 5, 2019 8:10 AM To: Ansible Project <ansible-project@googlegroups.com> Subject: Re: [ansible-project] using different remote_user until success loop a ping task over the users and use 'ignore_unreachable' and failed_when: false to keep running that task, register the result and set ansible_user using the results. -- ---------- Brian Coca -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7ewm22AQ7h9vG7qkfRL37-Zy8w7izdEGqQCD6trNrfKSw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout. -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/046e01d535a8%2477654100%24662fc300%24%40gmail.com. For more options, visit https://groups.google.com/d/optout.