win_package : passing arguments in the installation process - windows

I am trying to install tomcat on win2016 server. I need to select Full install as an install type when i do it manually. How can i replicate the same in the win_package s an argument. I tried few options but it didn't work out. Appreciate the help. The Playbook will Succeed but the installation doesn't happen.
- name: install
win_package:
path: https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.62/bin/apache-tomcat-9.0.62.exe
product_id: '{2821726D-A54C-47AF-97C7-34666DF5DD0A}'
state: present
arguments:
- /type="Full"

Related

Ansible script to uninstall multiple versions of OMS agent

I wanted to do an uninstallation of OMS agent in our Linux machines. Unfortunately, we do have different OMS agent versions assigned to each machine. I hard coded the version from my Ansible script
command: sudo {{ file_path }}/omsagent-1.13.9-0.universal.x64.sh —-purge
It only works for machine with that same OMS agent version else, it will fail.
I tried adding wildcard syntax, but it is getting an error stating that command not found
stderr: “sudo :/home/filename/omsagent-* : command not found
if I changed my previous command to
command: sudo {{file_path}}/omsagent-*.universal.x64.sh —-purge
Since I do not have this specific agent in place, I can't provide a full tested working example, but some some guidance.
According the package documentation and All bundle operations, the bundle has an option for
--version-check Check versions already installed to see if upgradable.
which should provide the installed version. Furthermore any installed agent has an directory with service control script
/opt/microsoft/omsagent/bin/service_control ...
and probably others, like scxadmin --version. By executing one or the other it should be possible to gather the correct installed version of the agent.
- name: Gather installed OMS agent version
become: true
become_method: sudo
shell:
cmd: /opt/microsoft/omsagent/bin/service_control status | grep <whatever is necessary to get the version string only>
register: VERSION
changed_when: false
check_mode: false
Please take note that instead of using sudo within the command, you should use become. Since it is a version reporting task only, you should also use changed_when and check_mode.
After the correct version is gathered you use it like
- name: Purge installed OMS agent version
become: true
become_method: sudo
shell:
cmd: "omsagent-{{ VERSION }}.universal.x64.sh —-purge"
Is there any reason why the option --upgrade or --force can`t be used?
You may also have a look into How to troubleshoot issues with the Log Analytics agent for Linux, there is a standalone versionless purge script available.

Run brew restart command using Homebrew module for Ansible

I have been trying to run the command
brew services restart nrpe
with the help of Ansible's homebrew module.
I have gone through the documentation (homebrew ansible doc) but I couldn't find an example which does a similar thing. I have tried the following:
- homebrew:
name: nrpe
state: present
install_options: services,restart
but it didn't work. Please let me know the correct way to run the command
brew services restart nrpe.
P.S. - Installation of nrpe or other services though homebrew is working great.
Edit 1 - Also including the Nagios tag because this might also be faced by the nagios community.
According to the documentation of the homebrew ansible module, the command :
brew services restart nrpe
seems not implemented. The solution could be to use the command module:
- name: restart the nrpe service
command: brew services restart nrpe

ERROR: yum is not a legal parameter in an Ansible task or handler

Long story short my PC died while I was running Vagrant and when I got power back my subsequent vagrant up attempted to rebuild the box. In doing so I got an error as the subject is titled:
ERROR: yum is not a legal parameter in an Ansible task or handler
I've tried double checking the ansible documentation, checking my structure and indentation, saving in different text editors etc but the error persists. I'm stuck as there was no issue previously so I am a bit stumped as to why it's no longer working.
My playbook is as follows, though i've cut a lot of it out for now while I resolve the issue:
---
- hosts: all
sudo: yes
tasks:
- name: Update yum packages
yum: name=* state=latest
Many thanks!
It turns out that I was missing a return after tasks.
---
- hosts: all
sudo: yes
tasks:
- name: Update yum packages
yum: name=* state=latest
However ansible playbook docs: http://docs.ansible.com/ansible/playbooks_intro.html examples show that no return is required after the tasks declaration.
Perhaps a nuance with my particular version (1.7.2)

Running a exe file on windows server using ansible

I am using the below ansible playbooks but it's not installing it, can anyone help?
- name: Install Firefox
hosts: wintestserverchandra
**tasks:**
- name: Firefox
raw: d:\install\firefox.exe
I used win_msi as well but no go.
Seems that you want to install Firefox via Ansible.
Just use the chocolatey Firefox package and install it with the win_chocolatey module:
- name: Install Firefox via chocolatey
win_chocolatey:
name: Firefox

ERROR! conflicting action statements (expect, command) in Ansible

I'm trying to install java on several hosts with Ansible.
I looked for some examples of expect module to provide answers to the prompts.
I think this syntax is quite fine:
- hosts: datanode
sudo: yes
sudo_user: root
tasks:
- expect:
name: install java jdk 7
command: apt-get install openjdk-7-jdk
responses:
Question:
'Do you want to continue? [Y/n]': 'Y'
But when I try to execute ansible-playbook file.yml I receive the error:
ERROR! conflicting action statements (expect, command)
The error appears to have been in '/root/scp.yml': line 5, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- expect:
^ here
Where is the problem?
(I have installed ansible 2.0.1.0, pexpect, python)
Thanks!
NOTE that Ansible works with yaml files, and this kind of files are indented. This means that the spaces you put before each statement are important to let Ansible to understand how are they nested. More info about yaml.
Corrected task:
- hosts: datanode
sudo: yes
sudo_user: root
tasks:
- name: install java jdk 7
expect:
command: apt-get install openjdk-7-jdk
responses:
Question:
- 'Y'
- 'n'
This will avoid your syntax error.
Source: http://docs.ansible.com/ansible/expect_module.html
Alternatively, if you always want to say "yes" to your apt-get install commands, you can add the -y argument:
apt-get install -y openjdk-7-jdk
Or even better, use the apt Ansible module.

Resources