no package matching is available in ansible version 2.7.10 - ansible

Can't install the packages in the virtual machine with ansible. Error: No package matching is available
---
- hosts: webservers
remote_user: root
#tasks:
# - name: test connection
# ping:
# remote_user: 192.168.33.10
#sudo: yes
tasks:
#- name: make sure apache is running
# service: name=httpd state=running
- name: General | Instalacion de paquetes requeridos.
action: apt pkg={{ item }} state=present
with_items:
-unzip
-mysql-server
-mysql-client
-apache2
-php-mysql
-php-apc
-php-xmlrpc
-php-soap
-php-gd
-php
-python-mysqldb
##
# Configuracion de Apache2
##
- name: Apache2 | Habilitar módulos
action: command a2enmod rewrite vhost_alias
##
# Reinicio de servicios
##
- name: Restart Apache
action: service name=apache2 state=restarted
Is there another option to do it, or how do I know what packages use', I tried installing a few packages at one, but failed too.
The complete error is:
PLAY [webservers] **************************************************************
TASK [Gathering Facts] *********************************************************
ok: [192.168.33.10]
TASK [General | Instalacion de paquetes requeridos.] ***************************
[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 pkg: "{{ item }}", please use pkg: '-unzip -mysql-server
-mysql-client -apache2 -php-mysql -php-apc -php-xmlrpc -php-soap -php-gd -php
-python-mysqldb' 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: [192.168.33.10] (item=[u'-unzip -mysql-server -mysql-client -apache2 -php-mysql -php-apc -php-xmlrpc -php-soap -php-gd -php -python-mysqldb']) => {"changed": false, "item": ["-unzip -mysql-server -mysql-client -apache2 -php-mysql -php-apc -php-xmlrpc -php-soap -php-gd -php -python-mysqldb"], "msg": "No package matching '-unzip -mysql-server -mysql-client -apache2 -php-mysql -php-apc -php-xmlrpc -php-soap -php-gd -php -python-mysqldb' is available"}
to retry, use: --limit #/home/guillermo/Documentos/vagrant-ansible/playbook.retry
PLAY RECAP *********************************************************************
192.168.33.10 : ok=1 changed=0 unreachable=0 failed=1

You have invalid YAML. A YAML list item is denoted by:
-<space><item>
Whereas you have:
-<item>
This is just a literal string. If you look at the error, you'll see the apt is trying to install packages with names like -unzip and -mysql-server, etc, which of course don't exist. You need to write your task like this:
- name: General | Instalacion de paquetes requeridos.
action: apt pkg={{ item }} state=present
with_items:
- unzip
- mysql-server
- mysql-client
- apache2
- php-mysql
- php-apc
- php-xmlrpc
- php-soap
- php-gd
- php
- python-mysqldb
But if you take another look at the error, you'll see:
Invoking "apt" only once while using a loop via squash_actions is deprecated...
It looks as if you've been learning Ansible based on outdated information. You should modernize your syntax to look like this:
- name: General | Instalacion de paquetes requeridos.
apt:
name: "{{ packages }}"
state: installed
vars:
packages:
- unzip
- mysql-server
- mysql-client
- apache2
- php-mysql
- php-apc
- php-xmlrpc
- php-soap
- php-gd
- php
- python-mysqldb

Related

Ansible - The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required

My ansible code looks like this:
---
- name: Install python
apt:
pkg: "{{ item }}"
update-cache: yes
state: latest
with_items:
- python
- python-dev
- name: Install pymysql
pip:
name: "{{ item }}"
executable: pip
state: present
with_items:
- PyMySQL==0.7.11
- MySQL-python
- name: Install mysql and deps
apt:
pkg: "{{ item }}"
update-cache: yes
state: latest
with_items:
- mysql-server
- libmysqlclient-dev
- python-mysqldb
- python-pip
- name: Create DB
mysql_db:
name: "{{ item }}"
collation: utf8_general_ci
encoding: utf8
with_items: "{{ database_names }}"
When I run it, I get the error,
failed: [xxxxx] (item=xxxxx) => {"ansible_loop_var": "item", "changed": false, "item": "xxxxx", "msg": "The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required."}
But from my sensible code you see I installed both PyMySQL and MySQL-python prior to calling mysql_db. Also, from ansible runtime log, I see both PyMySQL and MySQL-python got installed successfully:
TASK [mysql : Install python] **************************************************
ok: [aquila] => (item=python)
ok: [aquila] => (item=python-dev)
TASK [mysql : Install pymysql] *************************************************
ok: [aquila] => (item=PyMySQL==0.7.11)
ok: [aquila] => (item=MySQL-python)
TASK [mysql : Install mysql and deps] ******************************************
ok: [aquila] => (item=mysql-server)
ok: [aquila] => (item=libmysqlclient-dev)
ok: [aquila] => (item=python-mysqldb)
ok: [aquila] => (item=python-pip)
TASK [mysql : Create DB] ************************************************
failed: [xxxxx] (item=xxxxx) => {"ansible_loop_var": "item", "changed": false, "item": "aquila", "msg": "The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required."}
Why mysql-db is not getting the PyMySQL or MySQL-python module?
I have the same error on CentOS 7, but on Ubuntu 20.04 this works for me:
- name: Install pip
apt:
name: python3-pip
state: present
- name: Install PyMySQL
pip:
name: pymysql
state: present
UPD: Here's a solution on CentOS 7:
- name: Install MySQL-python
yum:
name:
- python3-pip
- MySQL-python

How can I resolve this ansible kerberos error?

I have Ubuntu 20.04 in WSL and Ansible installed. I'm trying to simply run a Windows update on my local machine. I've tried using my account, a service account, etc. I've run the kinit -C myuser#DOMAIN.LOCAL command and have a valid ticket. My computer is joined to an AD/Azure hybrid with the local domain being "domain.local", yet we login with myuser#domain.com to the computer.
I have the internal domain controllers listed in my /etc/resolv.conf so I can ping/access domain computers.
I've tried with ansible_user=myuser#DOMAIN.LOCAL, DOMAIN.COM, myuser, myuser#DOMAIN.COM
I keep getting errors when running "ansible-playbook -i hosts -vvvv win-update.yml":
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************
task path: /home/gmeyer/ansible/win-update.yml:5
Using module file /usr/lib/python3/dist-packages/ansible/modules/windows/setup.ps1
Pipelining is enabled.
<10.20.30.174> ESTABLISH WINRM CONNECTION FOR USER: myuser on PORT 5986 TO 10.20.30.174
fatal: [10.20.30.174]: UNREACHABLE! => {
"changed": false,
"msg": "kerberos: authGSSClientStep() failed: (('Unspecified GSS failure. Minor code may provide more information', 851968), ('Server not found in Kerberos database', -1765328377))",
"unreachable": true
}
PLAY RECAP ******************************************************************************************************************************************************************************************************`
10.20.30.174 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
My /etc/krb5.conf:
[libdefaults]
default_realm = DOMAIN.LOCAL
[realms]
X-ISS.LOCAL = {
kdc = dc.domain.local
admin_server = dc.domain.local
default_domain = domain.local
}
[domain_realm]
.domain.local = DOMAIN.LOCAL
domain.local = DOMAIN.LOCAL
My hosts:
[win]
10.20.30.174
[win:vars]
ansible_user=myuser#DOMAIN.LOCAL
ansible_connection = winrm
ansible_winrm_server_cert_validation = ignore
ansible_password = [redacted]
ansible_winrm_transport = kerberos
ansible_winrm_kerberos_delegation = true
My playbook:
---
# DESCRIPTION
# Apply windows updates
- name: Apply windows updates
hosts: win
gather_facts: yes
vars:
initial_reboot: |-
{{ 86400 <
(( ((ansible_date_time.date+" "+ansible_date_time.time)|to_datetime('%Y-%m-%d %H:%M:%S')) -
ansible_facts.lastboot|to_datetime('%Y-%m-%d %H:%M:%SZ')).total_seconds())|abs }}
tasks:
# Reboot systems with if up longer then day
# this way we know that the system was able to come back
# up before updates were applied
- name: Reboot if system has a large uptime
win_reboot:
when: initial_reboot and not ansible_check_mode
tags:
- never
- reboot
- block:
- name: >
{{ 'Install' if 'install' in ansible_run_tags else 'Search' }} updates
{{ 'will automatically reboot' if 'reboot' in ansible_run_tags else 'no reboot' }}
win_updates:
category_names:
- SecurityUpdates
- CriticalUpdates
- UpdateRollups
- DefinitionUpdates
- Updates
reboot: "{{ 'yes' if 'reboot' in ansible_run_tags else 'no' }}"
state: "{{ 'installed' if 'install' in ansible_run_tags else 'searched' }}"
become: yes
become_method: runas
become_user: SYSTEM
register: update_results
tags:
- never
- install
- check
rescue:
- name: Windows update failed?
debug:
msg: "error: {{ update_results.msg }}"
when: update_results is failed and update_results.msg is defined
tags:
- always
- name: Server had pending reboots?
win_reboot:
when: not ansible_check_mode and
update_results is failed and
update_results.msg is search('A reboot is required')
tags:
- never
- reboot
always:
- name: Report results
debug:
var: update_results
tags:
- never
- install
- check
I have tried many different options for formatting the domain name while running Ansible in Ubuntu. I am expecting to get the script to connect to the Windows machine to run the Windows Updates, but keep getting Kerberos errors.
I figured out what the problem was. It was in my hosts file - I changed the lines to the fqdn and put the "ansible_host=IP ansible_connection=local" and it worked!

Where is the syntax error in ansible-playbook?

I'm facing some (silly) problems with ansible-playbook. I don't understand the error due to is a syntax-error but another similar playbook has been executed successfully and this one not.
ERROR! 'copy' is not a valid attribute for a Play
The error appears to have been in '/home/manu/monitorizacion/node-exporter/playbooks/deploy-node-exporter.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: Upload project directory to '{{ docker_home }}'
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
The thing is that i have a (install.yml) playbook with 2 include_tasks
---
- hosts: wargame
vars:
project_home: ../../node-exporter/
scripts_dir: /home/docker/node-exporter/textfile-collector/
docker_home: /home/docker/node-exporter/
tasks:
- include_tasks: packages.yml
- include_tasks: deploy-node-exporter.yml
packages.yml is fine and it is executed without problem
---
- name: Instalar paquetes requeridos para Docker e instalación
apt:
update_cache: true
name: "{{ packages }}"
vars:
packages:
- lsb-core
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- python-setuptools
- python-pip
- git
- smartmontools
- name: Instalar clave Docker
apt_key:
url: https://download.docker.com/linux/debian/gpg
- name: Instalar repositorio Docker
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/debian {{ ansible_lsb.codename }} stable"
- name: Actualizar listado de paquetes
apt:
update_cache: yes
- name: Instalar Docker
apt:
name: docker-ce
- name: Instalar Docker-compose
pip:
name: docker-compose
- name: Grupo docker
group:
name: docker
state: present
- name: Usuario docker
user:
name: docker
group: docker
As you can see, the last executed task is "Usuario docker"
ok: [188.166.52.222] => {"append": false, "changed": false, "comment": "", "group": 998, "home": "/home/docker", "move_home": false, "name": "docker", "shell": "", "state": "present", "uid": 1002}
TASK [include_tasks] *****************************************************************************************************************************
fatal: [188.166.52.222]: FAILED! => {"reason": "no action detected in task. This often indicates a misspelled module name, or incorrect module path.\n\nThe error appears to have been in '/home/manu/monitorizacion/node-exporter/playbooks/deploy-node-exporter.yml': line 24, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n mode: '0755'\n- name: Deploy node-exporter\n ^ here\n"}
And now the error is in deploy-node-exporter.yml but the syntax is the same as in install.yml
---
- name: Upload project directory to '{{ docker_home }}'
copy:
src: "{{ project_home }}"
dest: "{{ docker_home }}"
directory_mode: yes
follow: yes
owner: docker
group: docker
- name: Fix perms for dirs
file:
path: "{{ item }}"
state: touch
mode: '0755'
with_items:
- "{{ docker_home }}"
- "{{ docker_home }}/textfile-collector"
- "{{ docker_home }}/playbooks"
- name: Give exec perms to smartmon.sh
file:
path: "{{ scripts_dir }}/smartmon.sh"
state: touch
mode: '0755'
- name: Deploy node-exporter
docker_compose:
project_src: "{{ docker_home }}"
build: no
state: present
recreate: always
register: output
- name: Creates cron entry for smartmon.sh
cron:
name: Cron job for collecting smartctl stats
minute: "*/15"
user: root
job: "{{ scripts_dir }}/smartmon.sh > {{ scripts_dir }}/smartmon.prom"
Or I'm blind due to i'm not able to find the syntax error or i think is an ansible problem
My current installed version
ansible 2.7.7
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.3.0]
--- update ---
I've put it everything on a single file
---
- hosts: myServer
vars:
project_home: ../../node-exporter/
scripts_dir: /home/docker/node-exporter/textfile-collector/
docker_home: /home/docker/node-exporter/
tasks:
- name: Instalar paquetes requeridos para Docker e instalación
apt:
update_cache: true
name: "{{ packages }}"
vars:
packages:
- lsb-core
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- python-setuptools
- python-pip
- git
- smartmontools
- name: Instalar clave Docker
apt_key:
url: https://download.docker.com/linux/debian/gpg
- name: Instalar repositorio Docker
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/debian {{ ansible_lsb.codename }} stable"
- name: Actualizar listado de paquetes
apt:
update_cache: yes
- name: Instalar Docker
apt:
name: docker-ce
- name: Instalar Docker-compose
pip:
name: docker-compose
- name: Grupo docker
group:
name: docker
state: present
- name: Usuario docker
user:
name: docker
group: docker
- name: Upload project directory to '{{ docker_home }}'
copy:
src: "../../node-exporter/"
dest: "/home/docker/node-exporter/"
directory_mode: yes
follow: yes
owner: docker
group: docker
- name: Fix perms for dirs
file:
path: "{{ item }}"
state: touch
mode: "0755"
with_items:
- "/home/docker/node-exporter/"
- "/home/docker/node-exporter/textfile-collector"
- "/home/docker/node-exporter/playbooks"
- name: Give exec perms to smartmon.sh
file:
path: "{{ scripts_dir }}/smartmon.sh"
state: touch
mode: "0755"
- name: Creating cron entry for smartmon.sh
cron:
name: Cron job for collecting smartctl stats
minute: "*/15"
user: root
job: "{{ scripts_dir }}/smartmon.sh > {{ scripts_dir }}/smartmon.prom"
In this file I've removed
- name: Deploying node-exporter
docker_compose:
project_src: "{{ docker_home }}"
build: no
state: present
recreate: always
register: output
And now it works (without this part of code)
┌─[root#hippi3c0w] - [~manu/monitorizacion/node-exporter/playbooks] - [sáb ago 31, 20:59]
└─[$] <git:(master*)> ansible-playbook install_new.yml --syntax-check
playbook: install_new.yml
But the problem comes back when i add this part to the yaml file, so the problem is without doubts following part
- name: Deploying node-exporter
docker_compose:
project_src: "{{ docker_home }}"
build: no
state: present
recreate: always
register: output
Do you know what could be the problem? Maybe docker_compose?
--- UPDATE ---
It was due to ansible version. 2.7 doesn't support docker_compose directive. Updated to 2.8.4 and now it works properly.
PLAY RECAP ***************************************************************************************************************************************
[MyIP] : ok=16 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
┌─[root#hippi3c0w] - [~manu/monitorizacion/node-exporter/playbooks] - [dom sep 01, 08:34]
└─[$] <git:(master*)> ansible --version; ansible-playbook install.yml --syntax-check
ansible 2.8.4
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.16+ (default, Jul 8 2019, 09:45:29) [GCC 8.3.0]
playbook: install.yml
Would you please be more specific about which error you want to solve.
This error?
- name: Upload project directory to '{{ docker_home }}'
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
Or That one?
ok: [188.166.52.222] => {"append": false, "changed": false, "comment": "", "group":
998, "home": "/home/docker", "move_home": false, "name": "docker", "shell": "",
"state": "present", "uid": 1002}
TASK [include_tasks]
fatal: [188.166.52.222]: FAILED! => {"reason": "no action detected in task. This
often indicates a misspelled module name, or incorrect module path.\n\nThe error
appears to have been in '/home/manu/monitorizacion/node-exporter/playbooks/deploy-
node-exporter.yml': line 24, column 3, but may\nbe elsewhere in the file depending
on the exact syntax problem.\n\nThe offending line appears to be:\n\n mode: '
0755'\n- name: Deploy node-exporter\n ^ here\n"}
JFYI
copy is possible in my ansible version
tasks:
- name: Test copy
copy:
src: "/home/manu/test"
dest: "/home/user"
follow: yes
owner: user
group: user
mode: 0755
└─[$] <git:(master*)> ansible-playbook test.yaml --syntax-check
playbook: test.yaml
┌─[root#hippi3c0w] - [~manu/monitorizacion/node-exporter/playbooks] - [sáb ago 31, 20:33]
└─[$] <git:(master*)> ansible-playbook test.yaml -u user -v
Using /etc/ansible/ansible.cfg as config file
/etc/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
PLAY [myserver] ***********************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************
ok: [myIP]
TASK [Test copy] *********************************************************************************************************************************
changed: [myIP] => {"changed": true, "checksum": "55ca6286e3e4f4fba5d0448333fa99fc5a404a73", "dest": "/home/user/test", "gid": 1001, "group": "user", "mode": "0755", "owner": "user", "path": "/home/user/test", "size": 3, "state": "file", "uid": 1001}
PLAY RECAP ***************************************************************************************************************************************
myIP : ok=2 changed=1 unreachable=0 failed=0
--- UPDATE ---
It was due to ansible version. 2.7 doesn't support docker_compose directive. Updated to 2.8.4 and now it works properly.
PLAY RECAP ***************************************************************************************************************************************
[MyIP] : ok=16 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
┌─[root#hippi3c0w] - [~manu/monitorizacion/node-exporter/playbooks] - [dom sep 01, 08:34]
└─[$] <git:(master*)> ansible --version; ansible-playbook install.yml --syntax-check
ansible 2.8.4
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.16+ (default, Jul 8 2019, 09:45:29) [GCC 8.3.0]
playbook: install.yml

Calling an Ansible task in a parent role with different values

I've created two very simple Ansible roles called base and web. web is dependent on base and this dependency is defined in web/meta/main.yml.
base has the following task defined in base/tasks/main.yml:
- name: install required packages
apt:
name: "{{ install_packages }}"
update_cache: "{{ apt_update_cache }}"
cache_valid_time: "{{ apt_cache_valid_time }}"
The variables in base are defined in base/defaults/main.yml:
apt_update_cache: yes
apt_cache_valid_time: 3600
install_packages:
- ufw
- sshguard
The variables in web are defined in web/defaults/main.yml:
install_packages:
- nginx
What I want to do is:
Call install required packages from base, using the install_packages variable from base, and apt_update_cache and apt_cache_valid_time from base.
Call install required packages from web, using the install_packages variable from web, and apt_update_cache and apt_cache_valid_time from base (since I haven't overridden either of those two in web).
Is this possible, and if so how would I go about doing it? Alternatively, is there a 'better' way to achieve the same result, without reproducing the task in every dependent role (I'm likely to create several others which depend on base, and they will all have their own role-specific tasks too)?
Here's one option.
For clarity, rename install_packages in roles/base/defaults/main.yml to base_packages:
---
base_packages:
- ufw
- sshguard
Rewrite your package installation task in roles/base/main.yml so that it looks like this:
---
- name: install required packages
apt:
name: "{{ base_packages + extra_packages|default([]) }}"
update_cache: "{{ apt_update_cache }}"
cache_valid_time: "{{ apt_cache_valid_time }}"
In roles/web/defaults/main.yml, define web_packages:
---
web_packages:
- nginx
And in roles/web/meta/main.yml, declare your dependency like this:
---
dependencies:
- role: base
vars:
extra_packages: "{{ web_packages }}"
If I replace that apt task with a debug task:
- name: install required packages
debug:
msg:
apt:
name: "{{ base_packages + extra_packages|default([]) }}"
update_cache: "{{ apt_update_cache }}"
cache_valid_time: "{{ apt_cache_valid_time }}"
And use this playbook:
---
- hosts: localhost
gather_facts: false
roles:
- web
I get the following output:
PLAY [localhost] ******************************************************************************
TASK [base : install required packages] *******************************************************
ok: [localhost] => {
"msg": {
"apt": {
"cache_valid_time": 3600,
"name": [
"ufw",
"sshguard",
"nginx"
],
"update_cache": true
}
}
}
PLAY RECAP ************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
As you can see, this installs both the packages declared in your base role as well as the packages from the web role.

ansible *when* say : "error while evaluating conditional"

I try to do something like that:
I have this playbook
---
- hosts: all
vars:
user: myuser
venv_name: venv
only_deploy_code: "yes"
roles:
- my_venv
In roles/my_venv/tasks/main.yml::
---
- name: pip Install packages into virtualenv
pip: name={{ item }} virtualenv="{{ home }}/{{ venv_name }}" virtualenv_site_packages="yes"
with_items:
- PyYAML
- numexpr
sudo_user: "{{ user }}"
sudo: true
when: only_code_deploy == "no"
but I get this error::
TASK: [akd_venv | pip Install packages into virtualenv]
***********************
fatal: [vagrant] => error while evaluating conditional: only_code_deploy == "no"
Just try to omit the quotes around the yes and change your when statement like this:
- hosts: all
gather_facts: no
vars:
only_deploy_code: yes
tasks:
- debug:
msg: "This is yes message"
when: not only_deploy_code
Tested on the local machine like this:
ansible-playbook -i "localhost," test.yml -c local
with the output:
PLAY ***************************************************************************
TASK [debug] *******************************************************************
skipping: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=0
I think this is the expected behaviour that you want, just modified the when statement if you want to skip it for no instead of yes like this:
when: only_deploy_code

Resources