Ansible win_chocolatey install_args - windows

I try to install oracle sql developer on windows host with ansible with this task:
- name: Install oracle-sql-developer
win_chocolatey:
name: oracle-sql-developer
version: '20.4.1.20210328'
state: present
install_args: "--params \"'/Username:{{ oracle_username }} /Password:{{ oracle_password }}'\""
The installation need /Username and /Password arguments but it's not working. I try many way to pass this arguments, but it doesn't work either. I always get this error message:
"ERROR: An Oracle account is required to download SQL Developer",
"",
" * Provide your Oracle credentials as package params to the installer and",
" retry the installation:",
"",
" choco install oracle-sql-developer --params \"'/Username:{userName} /Password:{password}'\""
How can I get these arguments right?

Related

Ansible on SLES: zypper plugin not able to install PostgreSQL 14

I am trying my hand on Ansible after having a very nice training in it. Currently, my task is to create a playbook that sets up a PostgreSQL cluster (with Patroni and etcd).
However, while installing PostgreSQL should be a pretty easy task, doing it using the zypper plugin throws an error. First, the part of the playbook that should install PostgreSQL:
- name: Installation PostgreSQL 14 Latest ohne Recommendations
become: true
zypper:
disable_recommends: true
name:
postgresql14-server
postgresql14-contrib
postgresql14-devel
update_cache: true
when: ansible_host in pgservers
The error message given is this:
fatal: [goeccdb22l]: FAILED! => {"changed": false, "cmd": ["/usr/bin/zypper", "--quiet", "--non-interactive", "--xmlout", "install", "--type", "package", "--auto-agree-with-licenses", "--no-recommends", "--", "+postgresql14-server postgresql14-contrib postgresql14-devel"], "msg": "No provider of '+postgresql14-server postgresql14-contrib postgresql14-devel' found.", "rc": 104, "stderr": "", "stderr_lines": [], "stdout": "<?xml version='1.0'?>\n<stream>\n<message type=\"error\">No provider of &apos;+postgresql14-server postgresql14-contrib postgresql14-devel&apos; found.</message>\n</stream>\n", "stdout_lines": ["<?xml version='1.0'?>", "<stream>", "<message type=\"error\">No provider of &apos;+postgresql14-server postgresql14-contrib postgresql14-devel&apos; found.</message>", "</stream>"]}
Let's extract the error message:
"msg": "No provider of '+postgresql14-server postgresql14-contrib postgresql14-devel' found."
I tried to replicate the problem using the shell on the target server. However, running the command seems to be able to install the packages:
ansible#goeccdb22l:~> sudo /usr/bin/zypper install --type package --auto-agree-with-licenses --no-recommends -- +postgresql14-server postgresql14-contrib postgresql14-devel
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 12 NEW packages are going to be installed:
libecpg6 libopenssl-1_1-devel libpq5 postgresql postgresql14 postgresql14-contrib postgresql14-devel postgresql14-server postgresql-contrib postgresql-devel postgresql-server zlib-devel
The following package needs additional customer contract to get support:
postgresql14
12 new packages to install.
Overall download size: 8.0 MiB. Already cached: 0 B. After the operation, additional 35.4 MiB will be used.
Continue? [y/n/v/...? shows all options] (y):
I've removed only the --quiet and --non-interactive options from the command, but kept all other given options.
The best idea I have is that the user/privilege escalation workings could be different from me logging in as the Ansible user to the target and just using sudo before the command.
Edit 1: I have developed an idea what the problem could be. As I mentioned above, when I tested the command, I removed two options: --quiet and --non-interactive. Testing the command with those two options gives the message:
The flag --quiet is not known.
However, using man zypper, I can clearly see that --quiet is a documented option:
-q, --quiet
Suppress normal output. Brief (esp. result notification) messages and error messages will still be printed, though. If used together with conflicting --verbose option, the --verbose option takes preference.
Now, my idea is that Ansible calls the command it documents in the return XML, but that because somehow --quiet is not understood it interprets that as nothing providing the requested package list. So that would leave two questions:
Why is --quiet not understood, yet documented? Is that a problem of SLES vs. OpenSuse?
How to work around that?
As the Ansible zypper module has no option to suppress the --quiet option I don't see any chance of working around it with parameters. The last option would be to split the zypper task into smaller shell tasks which I would like to avoid if possible.
So, with the help of a knowledgeable sysadmin I was able to diagnose the problem.
The list of packages documented above was not in fact a list. As I missed the dashes in front of the packages, Ansible accepted the packages with the newlines and everything as one package name and tried to install it.
The solution is to change the packages into a list of packages by prefixing them with dashes/minus signs.
The problem with --quiet was that it is a positional argument, and I used the wrong position when testing it.

salt receipt for a pip install

I have an state in a salt receipt that fails to install some sources using pip. But using pip from the shell what I think is the equivalent works. So it isn't really the equivalent and there something I miss that I cannot see.
I like to mention at the very beginning that the minion doesn't have full internet access and it shouldn't have.
{% set PLUGINSSRC='/usr/local/src' %}
git_sardana-xaira:
git.latest:
- name: https://...
- target: {{ PLUGINSSRC }}/sardana_xaira
- rev: 0.0.1
pip_git_sardana-xaira:
pip.installed:
- onchanges:
- git: git_sardana-xaira
- target: {{ PLUGINSSRC }}/sardana_xaira
- bin_env: '/usr/bin/pip3'
- no_deps: True
- require:
- pkg: python3-pip
The reduced return of this is:
ID: pip_git_sardana-xaira
Function: pip.installed
Result: False
Comment: Failed to install packages: pip_git_sardana-xaira. Error: Collecting pip_git_sardana-xaira Exception:
(...)
socket.gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
(...)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3b474fe400>: Failed to establish a new connection: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
(...)
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
But if, instead of use salt, I use the shell in the minion:
$ export PLUGINSSRC=/usr/local/src
$ sudo /usr/bin/pip3 install $PLUGINSSRC/sardana_xaira --no-deps
$ /usr/bin/pip3 list | grep xaira
sardana-xaira (0.0.1)
There would be something missing in the salt state that produces a different execution than the one in the shell. I also like to find which connection is failing when I use salt.
Following the documentation of the pip state there is a difference between name and target.
name
The name of the python package to install. You can also specify version numbers here using the standard operators ==, >=, <=. If requirements is given, this parameter will be ignored.
target
Install packages into target dir
The original receipt posted here was misunderstanding those two parameters.
The receipt that corresponds with the shell equivalent for pip would be:
pip_git_sardana-xaira:
pip.installed:
- onchanges:
- git: git_sardana-xaira
- name: {{ PLUGINSSRC }}/sardana_xaira
- bin_env: '/usr/bin/pip3'
- no_deps: True
- require:
- pkg: python3-pip

When I use ansible module expect, I got this msg: The pexpect python module is required

I am trying to use ansible to deploy our system. I used expect module in yml file and try using ansible-playbook to run it and got this error:
fatal: [192.168.100.132]: FAILED! => {"changed": false, "failed":
true, "msg": "The pexpect python module is required"}
Then I downloaded the pexpect-4.2.1 package from pypi.python.org and install it by "python setup.py install".
But it doesn't work and error never changed.
What should I do to deal with the error ?
Some code from yml file:
- name: auth root
expect:
command: mysql_secure_installation
responses:
'Enter password for user root:': '{{password.stdout}}'
'New password:': 'dtise123'
'Re-enter new password:': 'dtise123'
'Do you wish to continue with the password provided\?\(Press y\|Y for Yes, any other key for No\) :': 'y'
'Remove anonymous users\? \(Press y\|Y for Yes, any other key for No\) :': 'y'
'Disallow root login remotely\? \(Press y\|Y for Yes, any other key for No\) :': 'y'
'Remove test database and access to it\? \(Press y\|Y for Yes, any other key for No\) :': 'y'
'Reload privilege tables now\? \(Press y\|Y for Yes, any other key for No\) :': 'y'
echo: yes
I downloaded the pexpect-4.2.1.tar.gz from pypi.python.org and did like this:
mv pexpect-4.2.1.tar.gz /usr/local/src/
cd /usr/local/src
tar zxvf pexpect-4.2.1.tar.gz
cd pexpect-4.2.1
python setup.py install
I installed it [pexpect] on the Ansible host. Do I need to install it on each node machine?
Yes, modules are executed on target machines and prerequisites (if they exist) must be installed on them.

Ansible copy fails

I was trying to copy a test file from a Linux control server to a Windows 7 client. my playbook is
- name: Test Copy from Linux to Windows
hosts: Windows
gather_facts: false
tasks:
- name: Copy
copy: src=/tmp/tmp.txt dest=C:\Ansible
And getting this error
failed: [10.8.0.4] => {"failed": true, "md5sum": "c9566265d534d0e3c666ea52daf96cc8", "parsed": false}
invalid output was: The argument 'C:\Users\me.HOMEPC\AppData\Local\Temp\ansible-tmp-1422383762.86-109261083693479\\copy.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
FATAL: all hosts have already failed -- aborting
Any thoughts? How I can make this work?
There's a small bug in that fork version. Use https://gist.github.com/dmitrydigi/dc4843fca7e69bcca147 with the fix. If you use the mentioned version, then template will always report changed=true.
Looks like the copy module doesn't support for file copy function in Windows and atm, a win_copy module is in the dev phase.
However I have found this VERY useful module which is copy.ps1
https://gist.github.com/tkinz27/fd92ba9af0e0309614ee
And then things got working :-)
Important: You gotta upgrade your Windows (7) Powershell to Version 4.0

puppet can't find pip : Parameter provider failed: Invalid package provider 'pip' at < path_to_pip_file >

I have a simple .pp / puppet file, and I'm getting "Parameter provider failed: Invalid package provider 'pip' at sis.pp:24"
Here's the line 24:
20 package {"numpy":
21 ensure => installed,
22 provider => pip,
23 require => Package["python-setuptools", "python-pip", "python-dev", "build-essential"]
24 }
I checked for syntax errors, there are none.
My guess is that puppet can't find pip, I uninstalled and installed pip again. With apt-get,
here's what i get when i type "whereis pip"
pip: /usr/local/bin/pip /usr/share/man/man1/pip.1.gz
I searched around and found that puppet has a pip module, installed it too.
But still clueless about what the problem is.
When I type "puppet apply sis.pp --debug --verbose"
I get this:
debug: Puppet::Type::Package::ProviderSunfreeware: file pkg-get does not exist
debug: Puppet::Type::Package::ProviderFink: file /sw/bin/fink does not exist
debug: Puppet::Type::Package::ProviderYum: file yum does not exist
debug: Puppet::Type::Package::ProviderRug: file /usr/bin/rug does not exist
debug: Puppet::Type::Package::ProviderAix: file /usr/bin/lslpp does not exist
debug: Puppet::Type::Package::ProviderPorts: file /usr/sbin/pkg_info does not exist
debug: Puppet::Type::Package::ProviderNim: file /usr/sbin/nimclient does not exist
debug: Puppet::Type::Package::ProviderRpm: file rpm does not exist
debug: Puppet::Type::Package::ProviderSun: file /usr/sbin/pkgrm does not exist
debug: Puppet::Type::Package::ProviderPortupgrade: file /usr/sbin/pkg_info does not exist
debug: Puppet::Type::Package::ProviderHpux: file /usr/sbin/swremove does not exist
debug: Puppet::Type::Package::ProviderZypper: file /usr/bin/zypper does not exist
debug: Puppet::Type::Package::ProviderFreebsd: file /usr/sbin/pkg_delete does not exist
debug: Puppet::Type::Package::ProviderUp2date: file /usr/sbin/up2date-nox does not exist
debug: Puppet::Type::Package::ProviderPkg: file /usr/bin/pkg does not exist
debug: Puppet::Type::Package::ProviderPortage: file /usr/bin/eix does not exist
debug: Puppet::Type::Package::ProviderAptrpm: file rpm does not exist
debug: Puppet::Type::Package::ProviderOpenbsd: file pkg_delete does not exist
debug: Puppet::Type::Package::ProviderUrpmi: file urpmq does not exist
Parameter provider failed: Invalid package provider 'pip' at /path/sis.pp:54
Observe the puppet interpreter is pointing to multiple places in the sis.pp file where it couldn't process provider => "pip"
need help. I'm now going to try and find the terminal output code lines in puppet source to see what the problem is. If somebody knows the solution already, help would be appreciated.
I'm on ubuntu.
It appears your installation can't find the pip provider, rather than it not being able to find the pip executable.
I'm guessing the provider you mentioned is this one:
https://github.com/rcrowley/puppet-pip
Couple of things that might not be clear:
The plugin needs to be available on the puppet clients
Just installing the Gem won't do it for you, hence the manual env setting in the README
Probably the easiest approach is to include the puppet-pip provider in your puppet repo as a separate module, and then enable pluginsync, i.e.
[main]
pluginsync = true
More details here http://docs.puppetlabs.com/guides/plugins_in_modules.html
It looks like pip provider is not available in puppet pre 2.7 without downloading an external provider. Are you using 2.7 or higher?

Resources