remove mysql

23 views
Skip to first unread message

Tony Wong

unread,
Jul 15, 2020, 11:39:21 AM7/15/20
to ansible...@googlegroups.com
trying to remove mysql from a previous install

--
- hosts: all
  become: true
  vars_files:
    - vars/default.yml

  tasks:
  - name: Uninstall MySQL packages.
    apt: name={{ item }} state=absent
    with_items:
      - mysql-server
      - mysql-client

but not working 


[Uninstall MySQL packages.] ****************************************************************************************************************
[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: ['mysql-server', 'mysql-client']` 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.
ok: [ubuntu2] => (item=[u'mysql-server', u'mysql-client'])






Stefan Hornburg (Racke)

unread,
Jul 15, 2020, 12:33:09 PM7/15/20
to ansible...@googlegroups.com
On 7/15/20 5:38 PM, Tony Wong wrote:
> trying to remove mysql from a previous install
>
> --
> - hosts: all
>   become: true
>   vars_files:
>     - vars/default.yml
>
>   tasks:
>   - name: Uninstall MySQL packages.
>     apt: name={{ item }} state=absent
>     with_items:
>       - mysql-server
>       - mysql-client
>
> but not working

To me it looks like it works (removing the packages), but your syntax is outdated.

It should be

apt:
name:
- mysql-server
- mysql-client


Regards
Racke

>
>
> [Uninstall MySQL packages.]
> ****************************************************************************************************************
> [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: ['mysql-server', 'mysql-client']` 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.
> ok: [ubuntu2] => (item=[u'mysql-server', u'mysql-client'])
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CALmkhkrCLRKxcYdgxW4C%2BjgvDgRu8_F%2BC-C8kNVdsV37HbGHqg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CALmkhkrCLRKxcYdgxW4C%2BjgvDgRu8_F%2BC-C8kNVdsV37HbGHqg%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Tony Wong

unread,
Jul 15, 2020, 12:56:14 PM7/15/20
to ansible...@googlegroups.com
this was the original install and I am just trying to reverse the installs

---

- hosts: all
  become: true
  vars_files:
    - vars/default.yml
tasks:
    - name: Install prerequisites
      apt: name={{ item }} update_cache=yes state=absent force_apt_get=yes
      loop: [ 'aptitude' ]

  #Apache Configuration
    - name: Install LAMP Packages
      apt: name={{ item }} update_cache=yes state=absent
      loop: [ 'apache2', 'mysql-server', 'python3-pymysql', 'php', 'php-mysql', 'libapache2-mod-php' ]

    - name: Create document root
      file:
        path: "/var/www/{{ http_host }}"
        state: directory
        owner: "{{ app_user }}"
        mode: '0755'

    - name: Set up Apache virtualhost
      template:
        src: "files/apache.conf.j2"
        dest: "/etc/apache2/sites-available/{{ http_conf }}"
      notify: Reload Apache

    - name: Enable new site
      shell: /usr/sbin/a2ensite {{ http_conf }}
      notify: Reload Apache

    - name: Disable default Apache site
      shell: /usr/sbin/a2dissite 000-default.conf
      when: disable_default
      notify: Reload Apache

  # MySQL Configuration
    - name: Sets the root password
      mysql_user:
        name: root
 

Tony Wong

unread,
Jul 15, 2020, 1:21:47 PM7/15/20
to ansible...@googlegroups.com
I tried this pb but its not uninstalling


--
- hosts: all
  become: true
  vars_files:
    - vars/default.yml

  tasks:
    - name: remove

      apt:
       name:
        - mysql-server
        - mysql-client
        - python3-pymysql
        - php
        - php-mysql
        - libapache2-mod-php

Dan Linder

unread,
Jul 15, 2020, 3:28:02 PM7/15/20
to Ansible Project
> I tried this pb but its not uninstalling

Can you be more specific?  What version of Ansible are you using, what version of Debian/Ubuntu is the server you're working on?

What is the output of this command when you run it on the machine you're wanting to remove the packages from:

     apt list | egrep '^mysql-server/|^mysql-client/|^python3-pymysql/|^php/|^libapache2-mod-php/'

Can you write a playbook with just the single task and run it with "-vvv" and paste the output in a response here?

The indenting in your previous example is slightly askew, and it is missing the "state: absent" parameter, but I'll make the assumption that is just a copy-and-paste error.

Stefan Hornburg (Racke)

unread,
Jul 15, 2020, 3:34:52 PM7/15/20
to ansible...@googlegroups.com
On 7/15/20 6:55 PM, Tony Wong wrote:
> this was the original install and I am just trying to reverse the installs
>
>

What is the distribution and the release of the target server(s)?

Regards
Racke
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CALmkhkoJqa11F8P6Y2SBKr94E8PhgNpAqR_GA8AW%2Bch5NH0QoQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CALmkhkoJqa11F8P6Y2SBKr94E8PhgNpAqR_GA8AW%2Bch5NH0QoQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
signature.asc

Tony Wong

unread,
Jul 16, 2020, 9:58:44 AM7/16/20
to ansible...@googlegroups.com
control server is ubuntu 19.10
client is 20.04

ok working now


are these 2 pb doing same thing?

---
- hosts: all
  become: true
  vars_files:
    - vars/default.yml

  tasks:
    - name: Install prerequisites
      apt:
       name:
        - apache2      
        - mysql-server
        - mysql-client
        - python3-pymysql
        - php
        - php-mysql
        - libapache2-mod-php
       update_cache: yes
       state: absent
       autoremove: yes
       purge: yes



---------------------------------------------------------


---
- hosts: all
  become: true
  vars_files:
    - vars/default.yml

  tasks:
    - name: Install prerequisites
      apt: name={{ item }} state=absent

      loop: [ 'aptitude' ]

      #Apache Configuration
    - name: Install LAMP Packages
      apt: name={{ item }} update_cache=yes state=absent autoremove=yes purge=yes

      loop: [ 'apache2', 'mysql-server', 'python3-pymysql', 'php', 'php-mysql', 'libapache2-mod-php' ]
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ed3037a6-ee6f-7e09-af51-740cd794ae27%40linuxia.de.

Dan Linder

unread,
Jul 16, 2020, 11:51:05 AM7/16/20
to Ansible Project
The actions that those two tasks perform look to be the same, but you should update the "name:" field to better reflect that the job is removing/un-installing those packages.
Reply all
Reply to author
Forward
0 new messages