builtin.expect question

43 views
Skip to first unread message

Rodrigo Reis

unread,
Jul 24, 2023, 3:11:31 PM7/24/23
to Ansible Project

Hello Everyone!

I trying to install ohmyzsh using ansible inside of a bigger yml file with a bunch of other sutff.
in hte ansible.builtin.expect block the goal is to anwser one  installation question but it waits for the timeou and display a huge error message.
Basically sucessfully install ohmyzsh but not awnser the installation question.
 
What you guys think, I'm doing wrong or have a better way to do it?


- name: Check if Oh My Zsh is installed
stat:
path: /home/rreis/.oh-my-zsh
register: ohmyzsh_installed

- name: Install Oh My Zsh
ansible.builtin.expect:
command: sh /home/rreis/install.sh
responses:
'Do you want to change your default shell to zsh? \[Y/n\]:': "Y\n"
timeout: 30
when: ohmyzsh_installed.stat.exists == false

Rowe, Walter P. (Fed)

unread,
Jul 24, 2023, 3:21:03 PM7/24/23
to ansible...@googlegroups.com
Are you certain your install.sh script produces that literal string as the prompt?

'Do you want to change your default shell to zsh? \[Y/n\]:': "Y\n"

You can use a regex in the key side of the dictionary.

'.*change your default shell to zsh.*': "Y\n"

Maybe your string isn't matching so it times out?

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

--
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3708b636-7b93-48e0-b119-65d24863bab7n%40googlegroups.com.

Will McDonald

unread,
Jul 24, 2023, 3:26:39 PM7/24/23
to ansible...@googlegroups.com
If you're just trying to find a way to ALWAYS say "yes, install" then looking at https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh#L37C31-L37C31 you could just pass in --unattended?

--

Rodrigo Reis

unread,
Jul 31, 2023, 10:15:01 AM7/31/23
to Ansible Project
Hi Guys!
Thank you for the responses
I Just used unnatend option and at the end have this chsh -s $(which zsh) to set the zsh as default shell. works like charm! 

I need to RTFM more.... thank's all! 

Rodrigo Reis

unread,
Jul 31, 2023, 10:15:05 AM7/31/23
to Ansible Project

guys!
Thank you for you response, unfortunettly change the respose not work but with --unnatend option I just ran "chsh -s $(which zsh)"after and voilá it is done!

Thank you very much for the support!
On Monday, July 24, 2023 at 4:26:39 PM UTC-3 Will McDonald wrote:
Reply all
Reply to author
Forward
0 new messages