I am trying to rename folder that is unpacked. So I can only get file name accurately with grep (or some sort of regex expression)
via ansible, the following command fails with the error message: stderr: mv: cannot stat /var/www/ls /var/www/ | grep client`': No such file or directory
Substitute "command" by "shell". The shell module allows to do piping, backticks, globs, etc.. The command module does not do any of those things and can only be used for a single static command line.
Yes, you need to use the shell module. However, much of this can be refactored.
curl should probably use the “get_url” module, etc.
There’s also the “unarchive” module, so you could do a local play to download the contents to the Ansible control machine and follow that up with unarchive to avoid the download happening on every host.