How to install Certbot via Ansible playbook? This is how I install Certbot in a Bash script:

apt-get update -y &amp;&amp; add-apt-repository ppa:certbot/certbot -y &amp;&amp; apt-get update -y
apt-get upgrade nginx python-certbot-nginx -y




That's the playbook syntax I found to install Nginx in default conf:

- hosts: localhost
    connection: local
    become: true

tasks:
    - name: install nginx
    apt: pkg=nginx state=installed update_cache=true


Is there no Ansible task to install Certbot as well, instead the above "heavier" Bash code?
Here is the direct Ansible translation of your bash install script:

- apt_repository:
    repo: 'ppa:certbot/certbot'

- apt:
    name: "{{ item }}"
    update_cache: yes
  with_items:
    - nginx
    - python-certbox-nginx