AWX Ansible - Dont read galaxy collections - ansible

I'm using AWX ansible ver 20.0 with kubernetes
My playbook:
---
- name: Install 7zip with offline package chocolatey
hosts: all
become: true
gather_facts: false
tasks:
- name: Create folder
win_file:
path: 'C:/Instalki'
state: directory
- name: Copy installer
become: true
win_copy:
src: "../playbooksWindows/installers/7zip.22.01.nupkg"
dest: "C:/Instalki/7zip.22.01.nupkg"
- name: install 7zip packages
win_chocolatey:
name: "7zip"
state: present
source: "C:/Instalki/7zip.22.01.nupkg"
- name : clear folder
win_file:
path: "C:/Instalki/7zip.22.01.nupkg"
state: absent
Error:
/usr/local/lib/python3.8/site-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated
"class": algorithms.Blowfish,
No config file found; using defaults
SSH password:
BECOME password[defaults to SSH password]:
ERROR! couldn't resolve module/action 'win_chocolatey'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/runner/project/playbooksWindows/Install_7zip.yml': line 27, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: install 7zip packages
^ here
My actual ansible collection on awx-ee container
# /usr/share/ansible/collections/ansible_collections
Collection Version
----------------------- -------
amazon.aws 4.1.0
ansible.posix 1.4.0
ansible.windows 1.11.1
awx.awx 21.5.0
azure.azcollection 1.13.0
community.vmware 2.9.1
google.cloud 1.0.2
kubernetes.core 2.3.2
openstack.cloud 1.9.1
ovirt.ovirt 2.2.3
redhatinsights.insights 1.0.7
theforeman.foreman 3.6.0
# /home/runner/.ansible/collections/ansible_collections
Collection Version
--------------------- -------
ansible.windows 1.11.1
chocolatey.chocolatey 1.3.0
I was installing collection with:
ansible-galaxy collection install chocolatey.chocolatey
Any ideas how to fix it on docker in ver AWX 17.01 everything works fine :/

Related

Install apache2 sqlite3 git - Ansible Loop

I have read all the similar questions here and yet I don't see a solution that fixed my issue.
This is my code:
---
- name: install apache2, sqlite3, git
tasks:
- name: Install list of packages
apt:
name: "{{ item }}"
state: installed
with_items:
- apache2
- sqlite3
- git
Here is the error:
ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>
The error appears to be in '/projects/challenge/fresco_loops/tasks/main.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: install apache2, sqlite3, git
^ here
I am not really an ansible expert and this is just one of the trainings we have to take. Thank you in advance.
firstly the best way to install multiple packages is shown below:
---
- name: install apache2, sqlite3, git
hosts: localhost # run locally
become: yes
tasks:
- name: Install list of packages
apt:
state: present
name:
- apache2
- sqlite3
- git
And a couple of final points:
"installed" is not a valid option for apt, try "present".
package installation requires sudo (become: yes).
To run the code above, which is locally on the node where the playbook sits, you need to use the command: ansible-playbook playbook.yml --ask-become-pass and enter the sudo password when prompted.
Secondly when I tried to run your code I got the following error
[DEPRECATION WARNING]: Invoking "apt" only once while using a loop via squash_actions is deprecated. Instead of using a loop to supply multiple items and specifying `name: "{{ item }}"`, please use `name: ['apache2', 'sqlite3',
'git']` and remove the loop. This feature will be removed in version 2.11. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
failed: [localhost] (item=['apache2', 'sqlite3', 'git']) => {"ansible_loop_var": "item", "changed": false, "item": ["apache2", "sqlite3", "git"], "msg": "value of state must be one of: absent, build-dep, fixed, latest, present, got: installed"}
When using Ansible 2.9.6, if you are using a different version that might explain it? Its always worth telling people what version you are using, in case the problem is version-specific.
Otherwise your code snippet is not representative of what is actually giving you the error.

How do I resolve an error in my yaml file?

I'm trying to install docker on a node using an ansible playbook, but I keep getting an error. Here's the playbook
---
- host: all
become: yes
become_user: root
tasks:
- name Add Docker GPG key
apt_key: url=https://download.docker.com/linux/ubuntu/gpg
- name: Add Docker APT repository
apt_repository:
repo: deb [arch=and64] https://download.docker.com/linux/ubuntu {{ansible_distributionrelease}} stable
- name: Install list of packages
apt:
name: "{{item}}"
state: installed
update_cache: yes
with_items:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- docker-ce
And here's the error message
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: No JSON object could be decoded
Syntax Error while loading YAML.
mapping values are not allowed in this context
The error appears to be in '/home/ubuntu/docker.yml': line 7, column 12, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name Add Docker GPG key
apt_key: url=https://download.docker.com/linux/ubuntu/gpg
^ here
What am I missing?
I realized my mistake. I was missing a colon on this line after 'name'
- name: Add Docker GPG key

Ansible - How to run multiple tasks in a playbook

I'm new to ansible, and am attempting to run multiple tasks to install docker on a particular host group in an ansible playbook.
I have the following playbook...
---
- hosts: all
tasks:
- name: Update and upgrade apt packages
become: yes
apt:
upgrade: yes
update_cache: yes
cache_valid_time: 86400 #One day
- hosts: loadbalancer
become: yes
tasks:
- name: Install docker packages
apt:
name:
- 'apt-transport-https'
- 'ca-certificates'
- 'curl'
- 'software-properties-common'
state: present
- name: Add Docker official GPG key
apt-key:
url: https://download.docker.com/linux/ubuntu/gpg
This is the error I get when attempting to run the playbook...
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to be in '/home/vagrant/ansible/playbooks/hostname.yml': line 23, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Add Docker official GPG key
^ here
What am I doing wrong here?
Thanks,
It is not apt-key, it is apt_key. Please update and try again

Required pip package missing when actually present?

I'm running the below ansible playbook, and am getting the following message
TASK [Set up pipeline] ***********************************************************************************************************************************************************************************************************************
fatal: [35.153.53.5]: FAILED! => {"changed": false, "msg": "python-jenkins required for this module. see http://python-jenkins.readthedocs.io/en/latest/install.html"}
to retry, use: --limit #~/Repositories/terraform-jenkins/ansible/jenkins.retry
Funny thing is.. it's actually present
[ec2-user#ip-172-31-43-13 ~]$ pip list |grep jenkins
jenkins-python 1.1
python-jenkins 1.3.0
[ec2-user#ip-172-31-43-13 ~]$ sudo !!
sudo pip list |grep jenkins
jenkins-python 1.1
python-jenkins 1.3.0
Ansible Version
ansible 2.6.4
config file = None
configured module search path = [u'/Users/jddaniel/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.15 (default, Jul 23 2018, 21:27:06) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
Verbose log
https://gist.github.com/ehime/ee08545fcb8e13d16ca801d1771d7461
Here's my playbook
#
# Ansible to provision Jenkins on remote host
#
- name: Install Jenkins and its plugins
hosts: all
become: yes
become_method: sudo
gather_facts: yes
pre_tasks:
- name: CA-Certificates update command line execution
command: /bin/update-ca-trust
vars:
jenkins_hostname: localhost
jenkins_http_port: 8080
roles:
- geerlingguy.repo-epel # required for pip
- geerlingguy.java
- geerlingguy.jenkins
tasks:
# TODO fix upstream
- name: Make Groovy folder writable
file:
path: /var/lib/jenkins/init.groovy.d
state: directory
# TODO verify this is what it should be
mode: 0777
- name: Install dependencies
yum:
name:
- git
- python2-pip
- name: Force upgrade pip
pip:
name: pip
extra_args: --upgrade
- name: Install dependencies for Jenkins modules
pip:
name: python-jenkins
- name: Install build pipeline
jenkins_plugin:
name:
- build-pipeline-plugin
- workflow-aggregator
url_username: "{{ jenkins_admin_username }}"
url_password: "{{ jenkins_admin_password }}"
- name: Set up pipeline
jenkins_job:
config: "{{ lookup('file', '_files/jobs.xml') }}"
name: test-auto
user: "{{ jenkins_admin_username }}"
password: "{{ jenkins_admin_password }}"
.... What could possibly be going on here? ...
Here's the jobs.xml if you want to try it on your lonesome
<?xml version='1.0' encoding='UTF-8'?>
<flow-definition plugin="workflow-job#2.10">
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
<triggers/>
</org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
</properties>
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps#2.30">
<script>
node { echo &apos;You get a pipeline, she gets a pipeline... you all get pipelines...&apos; }
</script>
<sandbox>true</sandbox>
</definition>
<triggers/>
</flow-definition>
OS info
[ec2-user#ip-172-31-43-13 ~]$ hostnamectl
Static hostname: ip-172-31-43-13.ec2.internal
Icon name: computer
Chassis: n/a
Machine ID: 8df22ad8f77c4d84bc36f0456b1fd0d7
Boot ID: 4981022b5a1c4d0d8bd659ca4ceeb071
Operating System: Red Hat Enterprise Linux Server 7.0 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.0:GA:server
Kernel: Linux 3.10.0-123.8.1.el7.x86_64
Architecture: x86_64
OS info is probably sketch as lsb_release isn't available... I'm using ami-a8d369c0 on AWS, which says it's RHEL 7.0 ... prob a stripped AMI? idk
No idea what the issue really was but yum installing instead of pip worked?

ANSIBLE doesn't work - syntax check

I'm trying to setup on ansible my first playbooks.
Hovever... no matter which example I'm trying to test.. i receive similar error:
"xyz is not a valid attribute for a Play"
For example:
$ cat a2.yml
- name: Update and upgrade
become: true
apt:
upgrade: yes
update_cache: yes
$ ansible-playbook a2.yml --syntax-check
ERROR! 'apt' is not a valid attribute for a Play
The error appears to have been in '/home/pi/My/ansible/a2.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Update and upgrade
^ here
Whats wrong?
PS.
$ ansible --version
ansible 2.4.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/pi/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170124]
See Playbooks Intro documentation.
Your entry should be a task item.
---
- hosts: ...
tasks:
- name: Update and upgrade
become: true
apt:
upgrade: yes
update_cache: yes

Resources