Streisand: Streisand fails on purging unneeded services.

Created on 7 Apr 2019  路  8Comments  路  Source: StreisandEffect/streisand

I have been trying to install streisand on AWS services but received the following error. I have been able to skip this step without further problems by changing main.yml file.

TASK [common : Purge unneeded services] ***********************************
fatal: [99.81.64.181]: FAILED! => {"changed": false, "msg": "'apt-get remove 'lxd' 'snapd'' failed: E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "rc": 100, "stderr": "E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "stderr_lines": ["E: Sub-process /usr/bin/dpkg returned an error code (1)"], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following packages will be REMOVED:\n lxd
snapd* ubuntu-core-launcher\n0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.\nAfter this operation, 112 MB disk space will be freed.\n(Reading database ... \r(Reading database ... 5%\r(Reading database ... 10%\r(Reading database ... 15%\r(Reading database ... 20%\r(Reading database ... 25%\r(Reading database ... 30%\r(Reading database ... 35%\r(Reading database ... 40%\r(Reading database ... 45%\r(Reading database ... 50%\r(Reading database ... 55%\r(Reading database ... 60%\r(Reading database ... 65%\r(Reading database ... 70%\r(Reading database ... 75%\r(Reading database ... 80%\r(Reading database ... 85%\r(Reading database ... 90%\r(Reading database ... 95%\r(Reading database ... 100%\r(Reading database ... 58863 files and directories currently installed.)\r\nRemoving lxd (2.0.11-0ubuntu1~16.04.4) ...\r\nWarning: Stopping lxd.service, but it can still be activated by:\r\n lxd.socket\r\nPurging configuration files for lxd (2.0.11-0ubuntu1~16.04.4) ...\r\nFailed to stop lxd.service: Unit lxd.service not loaded.\r\ndpkg: warning: while removing lxd, directory '/var/lib/lxd' not empty so not removed\r\nRemoving ubuntu-core-launcher (2.37.4ubuntu0.1) ...\r\nRemoving snapd (2.37.4ubuntu0.1) ...\r\nPurging configuration files for snapd (2.37.4ubuntu0.1) ...\r\nStopping snap.amazon-ssm-agent.amazon-ssm-agent.service\r\nStopping unit snap.amazon-ssm-agent.amazon-ssm-agent.service\r\nWaiting until unit snap.amazon-ssm-agent.amazon-ssm-agent.service is stopped [attempt 1]\r\nsnap.amazon-ssm-agent.amazon-ssm-agent.service is stopped.\r\nRemoving snap.amazon-ssm-agent.amazon-ssm-agent.service\r\nStopping snap-amazon\x2dssm\x2dagent-1068.mount\r\nStopping unit snap-amazon\x2dssm\x2dagent-1068.mount\r\nWaiting until unit snap-amazon\x2dssm\x2dagent-1068.mount is stopped [attempt 1]\r\nsnap-amazon\x2dssm\x2dagent-1068.mount is stopped.\r\nRemoving snap amazon-ssm-agent and revision 1068\r\nRemoving snap-amazon\x2dssm\x2dagent-1068.mount\r\nStopping snap-core-6673.mount\r\nStopping unit snap-core-6673.mount\r\nWaiting until unit snap-core-6673.mount is stopped [attempt 1]\r\nsnap-core-6673.mount is stopped.\r\nRemoving snap core and revision 6673\r\nRemoving snap-core-6673.mount\r\nFinal directory cleanup\r\nDiscarding preserved snap namespaces\r\nRemoving extra snap-confine apparmor rules\r\nRemoving snapd cache\r\nrm: cannot remove '/var/cache/snapd/aux': Is a directory\r\ndpkg: error processing package snapd (--purge):\r\n subprocess installed post-removal script returned error exit status 1\r\nProcessing triggers for man-db (2.7.5-1) ...\r\nProcessing triggers for mime-support (3.59ubuntu1) ...\r\nErrors were encountered while processing:\r\n snapd\r\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "The following packages will be REMOVED:", " lxd snapd* ubuntu-core-launcher*", "0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.", "After this operation, 112 MB disk space will be freed.", "(Reading database ... ", "(Reading database ... 5%", "(Reading database ... 10%", "(Reading database ... 15%", "(Reading database ... 20%", "(Reading database ... 25%", "(Reading database ... 30%", "(Reading database ... 35%", "(Reading database ... 40%", "(Reading database ... 45%", "(Reading database ... 50%", "(Reading database ... 55%", "(Reading database ... 60%", "(Reading database ... 65%", "(Reading database ... 70%", "(Reading database ... 75%", "(Reading database ... 80%", "(Reading database ... 85%", "(Reading database ... 90%", "(Reading database ... 95%", "(Reading database ... 100%", "(Reading database ... 58863 files and directories currently installed.)", "Removing lxd (2.0.11-0ubuntu1~16.04.4) ...", "Warning: Stopping lxd.service, but it can still be activated by:", " lxd.socket", "Purging configuration files for lxd (2.0.11-0ubuntu1~16.04.4) ...", "Failed to stop lxd.service: Unit lxd.service not loaded.", "dpkg: warning: while removing lxd, directory '/var/lib/lxd' not empty so not removed", "Removing ubuntu-core-launcher (2.37.4ubuntu0.1) ...", "Removing snapd (2.37.4ubuntu0.1) ...", "Purging configuration files for snapd (2.37.4ubuntu0.1) ...", "Stopping snap.amazon-ssm-agent.amazon-ssm-agent.service", "Stopping unit snap.amazon-ssm-agent.amazon-ssm-agent.service", "Waiting until unit snap.amazon-ssm-agent.amazon-ssm-agent.service is stopped [attempt 1]", "snap.amazon-ssm-agent.amazon-ssm-agent.service is stopped.", "Removing snap.amazon-ssm-agent.amazon-ssm-agent.service", "Stopping snap-amazon\x2dssm\x2dagent-1068.mount", "Stopping unit snap-amazon\x2dssm\x2dagent-1068.mount", "Waiting until unit snap-amazon\x2dssm\x2dagent-1068.mount is stopped [attempt 1]", "snap-amazon\x2dssm\x2dagent-1068.mount is stopped.", "Removing snap amazon-ssm-agent and revision 1068", "Removing snap-amazon\x2dssm\x2dagent-1068.mount", "Stopping snap-core-6673.mount", "Stopping unit snap-core-6673.mount", "Waiting until unit snap-core-6673.mount is stopped [attempt 1]", "snap-core-6673.mount is stopped.", "Removing snap core and revision 6673", "Removing snap-core-6673.mount", "Final directory cleanup", "Discarding preserved snap namespaces", "Removing extra snap-confine apparmor rules", "Removing snapd cache", "rm: cannot remove '/var/cache/snapd/aux': Is a directory", "dpkg: error processing package snapd (--purge):", " subprocess installed post-removal script returned error exit status 1", "Processing triggers for man-db (2.7.5-1) ...", "Processing triggers for mime-support (3.59ubuntu1) ...", "Errors were encountered while processing:", " snapd"]}

I believe this is due to a change in removing "snapd".

Most helpful comment

Just so everyone else know it, I managed to get server up and running by updating playbooks/roles/common/tasks/main.yml:

- name: Purge unneeded services
  apt:
    package: "{{ streisand_unneeded_packages }}"
    state: "absent"
    purge: no
    autoremove: no

All 8 comments

I ran into the same issue.

### Ansible Information

* Ansible version: 2.6.5
* Ansible system: Linux
* Host OS: Ubuntu
* Host OS version:  16.04
* Python interpreter: python
* Python version: 2.7.12

### Streisand Information

* Streisand Git revision: 8f06cadd1500c7cdc02889fe1683d1124e00f78b
* Streisand Git clone has untracked changes: no
* Genesis role: genesis-amazon
* Custom SSH key: True

### Enabled Roles

* Shadowsocks enabled:  True
* Wireguard enabled: True
* OpenVPN enabled: True
* stunnel enabled: True
* Tor enabled: False
* Openconnect enabled: True
* TinyProxy enabled: True
* SSH forward user enabled: True
* Configured number of VPN clients: 3

Same issue.
FAILED! => {"changed": false, "msg": "'apt-get remove 'lxd' 'snapd'' failed: E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "rc": 100, "stderr": "E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "stderr_lines": ["E: Sub-process /usr/bin/dpkg returned an error code (1)"], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following packages will be REMOVED:\n lxd* snapd* ubuntu-core-launcher*\n0 upgraded, 0 newly installed, 3 to remove and 7 not upgraded.\nAfter this operation, 112 MB disk space will be freed.\n(Reading database ... \r(Reading database ... 5%\r(Reading database ... 10%\r(Reading database ... 15%\r(Reading database ... 20%\r(Reading database ... 25%\r(Reading database ... 30%\r(Reading database ... 35%\r(Reading database ... 40%\r(Reading database ... 45%\r(Reading database ... 50%\r(Reading database ... 55%\r(Reading database ... 60%\r(Reading database ... 65%\r(Reading database ... 70%\r(Reading database ... 75%\r(Reading database ... 80%\r(Reading database ... 85%\r(Reading database ... 90%\r(Reading database ... 95%\r(Reading database ... 100%\r(Reading database ... 58863 files and directories currently installed.)\r\nRemoving lxd (2.0.11-0ubuntu1~16.04.4) ...\r\nWarning: Stopping lxd.service, but it can still be activated by:\r\n lxd.socket\r\nPurging configuration files for lxd (2.0.11-0ubuntu1~16.04.4) ...\r\nFailed to stop lxd.service: Unit lxd.service not loaded.\r\ndpkg: warning: while removing lxd, directory '/var/lib/lxd' not empty so not removed\r\nRemoving ubuntu-core-launcher (2.37.4ubuntu0.1) ...\r\nRemoving snapd (2.37.4ubuntu0.1) ...\r\nPurging configuration files for snapd (2.37.4ubuntu0.1) ...\r\nStopping snap.amazon-ssm-agent.amazon-ssm-agent.service\r\nStopping unit snap.amazon-ssm-agent.amazon-ssm-agent.service\r\nWaiting until unit snap.amazon-ssm-agent.amazon-ssm-agent.service is stopped [attempt 1]\r\nsnap.amazon-ssm-agent.amazon-ssm-agent.service is stopped.\r\nRemoving snap.amazon-ssm-agent.amazon-ssm-agent.service\r\nStopping snap-amazon\\x2dssm\\x2dagent-1068.mount\r\nStopping unit snap-amazon\\x2dssm\\x2dagent-1068.mount\r\nWaiting until unit snap-amazon\\x2dssm\\x2dagent-1068.mount is stopped [attempt 1]\r\nsnap-amazon\\x2dssm\\x2dagent-1068.mount is stopped.\r\nRemoving snap amazon-ssm-agent and revision 1068\r\nRemoving snap-amazon\\x2dssm\\x2dagent-1068.mount\r\nStopping snap-core-6673.mount\r\nStopping unit snap-core-6673.mount\r\nWaiting until unit snap-core-6673.mount is stopped [attempt 1]\r\nsnap-core-6673.mount is stopped.\r\nRemoving snap core and revision 6673\r\nRemoving snap-core-6673.mount\r\nFinal directory cleanup\r\nDiscarding preserved snap namespaces\r\nRemoving extra snap-confine apparmor rules\r\nRemoving snapd cache\r\nrm: cannot remove '/var/cache/snapd/aux': Is a directory\r\ndpkg: error processing package snapd (--purge):\r\n subprocess installed post-removal script returned error exit status 1\r\nProcessing triggers for man-db (2.7.5-1) ...\r\nProcessing triggers for mime-support (3.59ubuntu1) ...\r\nErrors were encountered while processing:\r\n snapd\r\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "The following packages will be REMOVED:", " lxd* snapd* ubuntu-core-launcher*", "0 upgraded, 0 newly installed, 3 to remove and 7 not upgraded.", "After this operation, 112 MB disk space will be freed.", "(Reading database ... ", "(Reading database ... 5%", "(Reading database ... 10%", "(Reading database ... 15%", "(Reading database ... 20%", "(Reading database ... 25%", "(Reading database ... 30%", "(Reading database ... 35%", "(Reading database ... 40%", "(Reading database ... 45%", "(Reading database ... 50%", "(Reading database ... 55%", "(Reading database ... 60%", "(Reading database ... 65%", "(Reading database ... 70%", "(Reading database ... 75%", "(Reading database ... 80%", "(Reading database ... 85%", "(Reading database ... 90%", "(Reading database ... 95%", "(Reading database ... 100%", "(Reading database ... 58863 files and directories currently installed.)", "Removing lxd (2.0.11-0ubuntu1~16.04.4) ...", "Warning: Stopping lxd.service, but it can still be activated by:", " lxd.socket", "Purging configuration files for lxd (2.0.11-0ubuntu1~16.04.4) ...", "Failed to stop lxd.service: Unit lxd.service not loaded.", "dpkg: warning: while removing lxd, directory '/var/lib/lxd' not empty so not removed", "Removing ubuntu-core-launcher (2.37.4ubuntu0.1) ...", "Removing snapd (2.37.4ubuntu0.1) ...", "Purging configuration files for snapd (2.37.4ubuntu0.1) ...", "Stopping snap.amazon-ssm-agent.amazon-ssm-agent.service", "Stopping unit snap.amazon-ssm-agent.amazon-ssm-agent.service", "Waiting until unit snap.amazon-ssm-agent.amazon-ssm-agent.service is stopped [attempt 1]", "snap.amazon-ssm-agent.amazon-ssm-agent.service is stopped.", "Removing snap.amazon-ssm-agent.amazon-ssm-agent.service", "Stopping snap-amazon\\x2dssm\\x2dagent-1068.mount", "Stopping unit snap-amazon\\x2dssm\\x2dagent-1068.mount", "Waiting until unit snap-amazon\\x2dssm\\x2dagent-1068.mount is stopped [attempt 1]", "snap-amazon\\x2dssm\\x2dagent-1068.mount is stopped.", "Removing snap amazon-ssm-agent and revision 1068", "Removing snap-amazon\\x2dssm\\x2dagent-1068.mount", "Stopping snap-core-6673.mount", "Stopping unit snap-core-6673.mount", "Waiting until unit snap-core-6673.mount is stopped [attempt 1]", "snap-core-6673.mount is stopped.", "Removing snap core and revision 6673", "Removing snap-core-6673.mount", "Final directory cleanup", "Discarding preserved snap namespaces", "Removing extra snap-confine apparmor rules", "Removing snapd cache", "rm: cannot remove '/var/cache/snapd/aux': Is a directory", "dpkg: error processing package snapd (--purge):", " subprocess installed post-removal script returned error exit status 1", "Processing triggers for man-db (2.7.5-1) ...", "Processing triggers for mime-support (3.59ubuntu1) ...", "Errors were encountered while processing:", " snapd"]}

Same issue
TASK [common : Purge unneeded services] ************
fatal: [52.64.174.232]: FAILED! => {"changed": false, "msg": "'apt-get remove 'lxd' 'snapd'' failed: E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "rc": 100, "stderr": "E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "stderr_lines": ["E: Sub-process /usr/bin/dpkg returned an error code (1)"], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following packages will be REMOVED:\n lxd* snapd* ubuntu-core-launcher\n0 upgraded, 0 newly installed, 3 to remove and 7 not upgraded.\nAfter this operation, 112 MB disk space will be freed.\n(Reading database ... \r(Reading database ... 5%\r(Reading database ... 10%\r(Reading database ... 15%\r(Reading database ... 20%\r(Reading database ... 25%\r(Reading database ... 30%\r(Reading database ... 35%\r(Reading database ... 40%\r(Reading database ... 45%\r(Reading database ... 50%\r(Reading database ... 55%\r(Reading database ... 60%\r(Reading database ... 65%\r(Reading database ... 70%\r(Reading database ... 75%\r(Reading database ... 80%\r(Reading database ... 85%\r(Reading database ... 90%\r(Reading database ... 95%\r(Reading database ... 100%\r(Reading database ... 58863 files and directories currently installed.)\r\nRemoving lxd (2.0.11-0ubuntu1~16.04.4) ...\r\nWarning: Stopping lxd.service, but it can still be activated by:\r\n lxd.socket\r\nPurging configuration files for lxd (2.0.11-0ubuntu1~16.04.4) ...\r\nFailed to stop lxd.service: Unit lxd.service not loaded.\r\ndpkg: warning: while removing lxd, directory '/var/lib/lxd' not empty so not removed\r\nRemoving ubuntu-core-launcher (2.37.4ubuntu0.1) ...\r\nRemoving snapd (2.37.4ubuntu0.1) ...\r\nPurging configuration files for snapd (2.37.4ubuntu0.1) ...\r\nStopping snap.amazon-ssm-agent.amazon-ssm-agent.service\r\nStopping unit snap.amazon-ssm-agent.amazon-ssm-agent.service\r\nWaiting until unit snap.amazon-ssm-agent.amazon-ssm-agent.service is stopped [attempt 1]\r\nsnap.amazon-ssm-agent.amazon-ssm-agent.service is stopped.\r\nRemoving snap.amazon-ssm-agent.amazon-ssm-agent.service\r\nStopping snap-amazon\x2dssm\x2dagent-1068.mount\r\nStopping unit snap-amazon\x2dssm\x2dagent-1068.mount\r\nWaiting until unit snap-amazon\x2dssm\x2dagent-1068.mount is stopped [attempt 1]\r\nsnap-amazon\x2dssm\x2dagent-1068.mount is stopped.\r\nRemoving snap amazon-ssm-agent and revision 1068\r\nRemoving snap-amazon\x2dssm\x2dagent-1068.mount\r\nStopping snap-core-6673.mount\r\nStopping unit snap-core-6673.mount\r\nWaiting until unit snap-core-6673.mount is stopped [attempt 1]\r\nsnap-core-6673.mount is stopped.\r\nRemoving snap core and revision 6673\r\nRemoving snap-core-6673.mount\r\nFinal directory cleanup\r\nDiscarding preserved snap namespaces\r\nRemoving extra snap-confine apparmor rules\r\nRemoving snapd cache\r\nrm: cannot remove '/var/cache/snapd/aux': Is a directory\r\ndpkg: error processing package snapd (--purge):\r\n subprocess installed post-removal script returned error exit status 1\r\nProcessing triggers for man-db (2.7.5-1) ...\r\nProcessing triggers for mime-support (3.59ubuntu1) ...\r\nErrors were encountered while processing:\r\n snapd\r\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "The following packages will be REMOVED:", " lxd snapd* ubuntu-core-launcher*", "0 upgraded, 0 newly installed, 3 to remove and 7 not upgraded.", "After this operation, 112 MB disk space will be freed.", "(Reading database ... ", "(Reading database ... 5%", "(Reading database ... 10%", "(Reading database ... 15%", "(Reading database ... 20%", "(Reading database ... 25%", "(Reading database ... 30%", "(Reading database ... 35%", "(Reading database ... 40%", "(Reading database ... 45%", "(Reading database ... 50%", "(Reading database ... 55%", "(Reading database ... 60%", "(Reading database ... 65%", "(Reading database ... 70%", "(Reading database ... 75%", "(Reading database ... 80%", "(Reading database ... 85%", "(Reading database ... 90%", "(Reading database ... 95%", "(Reading database ... 100%", "(Reading database ... 58863 files and directories currently installed.)", "Removing lxd (2.0.11-0ubuntu1~16.04.4) ...", "Warning: Stopping lxd.service, but it can still be activated by:", " lxd.socket", "Purging configuration files for lxd (2.0.11-0ubuntu1~16.04.4) ...", "Failed to stop lxd.service: Unit lxd.service not loaded.", "dpkg: warning: while removing lxd, directory '/var/lib/lxd' not empty so not removed", "Removing ubuntu-core-launcher (2.37.4ubuntu0.1) ...", "Removing snapd (2.37.4ubuntu0.1) ...", "Purging configuration files for snapd (2.37.4ubuntu0.1) ...", "Stopping snap.amazon-ssm-agent.amazon-ssm-agent.service", "Stopping unit snap.amazon-ssm-agent.amazon-ssm-agent.service", "Waiting until unit snap.amazon-ssm-agent.amazon-ssm-agent.service is stopped [attempt 1]", "snap.amazon-ssm-agent.amazon-ssm-agent.service is stopped.", "Removing snap.amazon-ssm-agent.amazon-ssm-agent.service", "Stopping snap-amazon\x2dssm\x2dagent-1068.mount", "Stopping unit snap-amazon\x2dssm\x2dagent-1068.mount", "Waiting until unit snap-amazon\x2dssm\x2dagent-1068.mount is stopped [attempt 1]", "snap-amazon\x2dssm\x2dagent-1068.mount is stopped.", "Removing snap amazon-ssm-agent and revision 1068", "Removing snap-amazon\x2dssm\x2dagent-1068.mount", "Stopping snap-core-6673.mount", "Stopping unit snap-core-6673.mount", "Waiting until unit snap-core-6673.mount is stopped [attempt 1]", "snap-core-6673.mount is stopped.", "Removing snap core and revision 6673", "Removing snap-core-6673.mount", "Final directory cleanup", "Discarding preserved snap namespaces", "Removing extra snap-confine apparmor rules", "Removing snapd cache", "rm: cannot remove '/var/cache/snapd/aux': Is a directory", "dpkg: error processing package snapd (--purge):", " subprocess installed post-removal script returned error exit status 1", "Processing triggers for man-db (2.7.5-1) ...", "Processing triggers for mime-support (3.59ubuntu1) ...", "Errors were encountered while processing:", " snapd"]}

Same.. 'apt-get remove 'lxd' 'snapd'' failed: E: Sub-process /usr/bin/dpkg returned an error code (1)

Just so everyone else know it, I managed to get server up and running by updating playbooks/roles/common/tasks/main.yml:

- name: Purge unneeded services
  apt:
    package: "{{ streisand_unneeded_packages }}"
    state: "absent"
    purge: no
    autoremove: no

Just so everyone else know it, I managed to get server up and running by updating playbooks/roles/common/tasks/main.yml:

- name: Purge unneeded services
  apt:
    package: "{{ streisand_unneeded_packages }}"
    state: "absent"
    purge: no
    autoremove: no

nice workaround, Thanks.

A less impactful edit can be done on playbooks/roles/common/vars/main.yml.

Update the streisand_unneeded_packages variable here to exclude snapd, as per @btabibian's comment.

# Services that are running by default but not needed by Streisand
streisand_unneeded_packages:
   - lxd
#  - snapd

This works but I run into further problems down the Ansible pipeline.

Was this page helpful?
0 / 5 - 0 ratings