Giter Club home page Giter Club logo

apt's People

Contributors

fcastello avatar frennkie avatar halostatue avatar klen avatar otakup0pe avatar pjan avatar sambaum avatar soupdiver avatar wyaeld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apt's Issues

Stop replacing /etc/apt/sources.list

Currently the sources.list the role uses to replace the existing one is ubuntu specific and USA centric (it seems also to be the ubuntu default..). It seems bad practice to insert this by default โ€“ suppose a base box has been tweaked to use EU repositories for instance.

Additionally ansible now has two modules for adding apt repositories:

apt_repository module
http://docs.ansible.com/apt_repository_module.html

apt_key module
http://docs.ansible.com/apt_key_module.html

Both these modules also work with both Debian and Ubuntu.

EDIT
Now I see you have 'apt_reset_source_list: no' so this won't be replaced by default! Sorry.
What's the reason for ever 'reset to default'?

make used release configurable

At the moment precise is hardcoded in templates/etc_apt_sources.list.j2. It makes sense to make the release configurable.

Patch to fix: "ANXS.apt : APT | Install Packages failed with No package(s) matching '['python3-apt'' available" error

I refactored out the combining of the two lists (see patch below) and that fixed the problem for me!

Environment:

  • roles/ANXS.apt/version: v2.1.0
  • ansible --version: ansible [core 2.14.6]
  • ansible_python_interpreter: /usr/bin/python3
  • os-release (host and target): VERSION="22.04.2 LTS (Jammy Jellyfish)"
  • defaults/main.yml vars not overriden

Log from ansible:

TASK [ANXS.apt : APT | Reset the sources list (/etc/apt/sources.list)] ************************************************************************************************************************************************************************************************************
skipping: [staging3.server.tld]

TASK [ANXS.apt : APT | Update the apt cache] **************************************************************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Remove packages that are no longer needed for dependencies] ************************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Remove .deb files for packages no longer on your system] ***************************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Check for cached .deb files] *******************************************************************************************************************************************************************************************************************************
skipping: [staging3.server.tld]

TASK [ANXS.apt : APT | Remove all cached .deb files] ******************************************************************************************************************************************************************************************************************************
skipping: [staging3.server.tld]

TASK [ANXS.apt : APT | Update the general configuration (/etc/apt/apt.conf.d/10general)] ******************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Make sure the required packages are installed 20.04 and above] *********************************************************************************************************************************************************************************************
ok: [staging3.server.tld]

TASK [ANXS.apt : APT | Make sure the required packages are installed 19.10 and below] *********************************************************************************************************************************************************************************************
skipping: [staging3.server.tld]

TASK [ANXS.apt : APT | Install Packages] ******************************************************************************************************************************************************************************************************************************************
failed: [staging3.server.tld] (item=['python3-apt', 'unattended-upgrades', 'apt-transport-https', 'curl', 'ca-certificates', 'software-properties-common'] + ['python3-apt']) => {"ansible_loop_var": "item", "changed": false, "item": "['python3-apt', 'unattended-upgrades', 'apt-transport-https', 'curl', 'ca-certificates', 'software-properties-common'] + ['python3-apt']", "msg": "No package(s) matching '['python3-apt'' available"}
	to retry, use: --limit @/home/ianh/Projects/Xbase/provision/tmp/ansible-retry/site.retry

PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************************
staging3.server.tld        : ok=6    changed=0    unreachable=0    failed=1    skipped=4    rescued=0    ignored=0   

Patch that fixed the problem for me (personally prefer running apt on default separately from version specific list anyway)

diff --git a/roles/ANXS.apt/tasks/main.yml b/roles/ANXS.apt/tasks/main.yml
index c7382dc..a4a9d2c 100644
--- a/roles/ANXS.apt/tasks/main.yml
+++ b/roles/ANXS.apt/tasks/main.yml
@@ -43,17 +43,19 @@
     group: root
     mode: 0644
 
+- name: APT | Install Default Packages
+  apt:
+    pkg: "{{apt_default_packages}}"
+    state: present
+
 - name: APT | Make sure the required packages are installed 20.04 and above
-  set_fact:
-    apt_packages_list: "{{ apt_default_packages }} + {{ apt_default_packages_post20 }}"
+  apt:
+    pkg: "{{apt_default_packages_post20}}"
+    state: present
   when: ansible_facts['distribution_version'] is version('20.04', '>=')
 
 - name: APT | Make sure the required packages are installed 19.10 and below
-  set_fact:
-    apt_packages_list: "{{ apt_default_packages }} + {{ apt_default_packages_pre20 }}"
+  apt:
+    pkg: "{{apt_default_packages_pre20}}"
+    state: present
   when: ansible_facts['distribution_version'] is version('20.04', '<')
-
-- name: APT | Install Packages
-  apt:
-    pkg: "{{apt_packages_list}}"
-    state: present

always says it is removing 'no longer needed' packages in australia

The task:

- name: APT | Remove packages that are no longer needed for dependencies
  shell: apt-get -y autoremove
  when: apt_autoremove
  register: autoremove_output
  changed_when: "'0 upgraded, 0 newly installed, 0 to remove' not in autoremove_output.stdout and 'not upgraded' not in autoremove_output.stdout"

Shows as always changing in australia because apt uses a different summary text ('not to upgrade') rather than ('not upgraded') - as an aussie I don't know why they bothered with the different text, but its breaking the test anyway (the 'dam' machine is a physical machine with a fresh ubunutu install with default options apart from selecting australia)

root@dam:~# dpkg -l apt
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                 Architecture            Description
+++-====================================-=======================-=======================-==============================================================================
ii  apt                                  1.0.1ubuntu2.8          amd64                   commandline package manager

root@dam:~# uname -a
Linux dam 3.16.0-41-generic #57~14.04.1-Ubuntu SMP Thu Jun 18 18:01:13 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

root@dam:~# cat /etc/issue
Ubuntu 14.04.2 LTS \n \l

root@dam:~# apt-get -y autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.

root@dam:~# locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX
root@dam:~# locale
LANG=en_AU.UTF-8
LANGUAGE=en_AU:en
LC_CTYPE="en_AU.UTF-8"
LC_NUMERIC="en_AU.UTF-8"
LC_TIME="en_AU.UTF-8"
LC_COLLATE="en_AU.UTF-8"
LC_MONETARY="en_AU.UTF-8"
LC_MESSAGES="en_AU.UTF-8"
LC_PAPER="en_AU.UTF-8"
LC_NAME="en_AU.UTF-8"
LC_ADDRESS="en_AU.UTF-8"
LC_TELEPHONE="en_AU.UTF-8"
LC_MEASUREMENT="en_AU.UTF-8"
LC_IDENTIFICATION="en_AU.UTF-8"
LC_ALL=
root@dam:~# 

Failing with Ansible 2.0.2.0 - template error unexpected char

FAILED! => {"failed": true, "msg": "The conditional check ''0 upgraded' failed.
  The error was: template error while templating string: unexpected char u\"'\" at 6.
  String: {% if '0 upgraded %} True {% else %} False {% endif %}"}

Looks like something to do with templating has changed between 2.0.0.0 and 2.0.2.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.