- با استفاده از این ماژول میتوان بستههای نرم افزارهای مختلف را بر روی توزیعهایی که بر پایه توزیع Debian هستند، نصب کرد.
- به عنوان مثال از این ماژول در توزیع Debian و Ubuntu استفاده میشود.
- به عنوان مثال دستور زیر باعث میشود تا :
- بستهی نرم افزار elinks بر روی گروهی خاص از خادمهای تحت مدیریت نصب شود.
|
1 |
# ansible -i hosts.list debian-servers -m <span style="color: #ff0000;">apt</span> -a "<span style="color: #ff0000;">name=elinks state=latest</span>" |
- در صورتی که دستور بالا به صورت موفقیت آمیز اجرا شده باشد، خروجیای مشابه زیر دریافت خواهید کرد :
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
172.16.0.247 | SUCCESS => { "cache_update_time": 1584044848, "cache_updated": false, "changed": true, "stderr": "", "stderr_lines": [], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n elinks-data libev4 libfsplib0 libgdbm-compat4 libgdbm6 libgpm2 liblua5.1-0\n libperl5.28 libtre5 perl perl-modules-5.28\nSuggested packages:\n elinks-doc gpm tre-agrep perl-doc libterm-readline-gnu-perl\n | libterm-readline-perl-perl make libb-debug-perl liblocale-codes-perl\nThe following NEW packages will be installed:\n elinks elinks-data libev4 libfsplib0 libgdbm-compat4 libgdbm6 libgpm2\n liblua5.1-0 libperl5.28 libtre5 perl perl-modules-5.28\n0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 8319 kB of archives.\nAfter this operation, 51.3 MB of additional disk space will be used.\nGet:1 http://mirror.aminidc.com/debian buster/main amd64 perl-modules-5.28 all 5.28.1-6 [2873 kB]\nGet:2 http://mirror.aminidc.com/debian buster/main amd64 libgdbm6 amd64 1.18.1-4 [64.7 kB]\nGet:3 http://mirror.aminidc.com/debian buster/main amd64 libgdbm-compat4 amd64 1.18.1-4 [44.1 kB]\nGet:4 http://mirror.aminidc.com/debian buster/main amd64 libperl5.28 amd64 5.28.1-6 [3883 kB]\nGet:5 http://mirror.aminidc.com/debian buster/main amd64 perl amd64 5.28.1-6 [204 kB]\nGet:6 http://mirror.aminidc.com/debian buster/main amd64 libev4 amd64 1:4.25-1 [39.0 kB]\nGet:7 http://mirror.aminidc.com/debian buster/main amd64 libfsplib0 amd64 0.11-2 [14.6 kB]\nGet:8 http://mirror.aminidc.com/debian buster/main amd64 libgpm2 amd64 1.20.7-5 [35.1 kB]\nGet:9 http://mirror.aminidc.com/debian buster/main amd64 liblua5.1-0 amd64 5.1.5-8.1+b2 [111 kB]\nGet:10 http://mirror.aminidc.com/debian buster/main amd64 libtre5 amd64 0.8.0-6 [58.5 kB]\nGet:11 http://mirror.aminidc.com/debian buster/main amd64 elinks-data all 0.13~20190125-3 [383 kB]\nGet:12 http://mirror.aminidc.com/debian buster/main amd64 elinks amd64 0.13~20190125-3 [608 kB]\nFetched 8319 kB in 32s (256 kB/s)\nSelecting previously unselected package perl-modules-5.28.\r\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 ... 35146 files and directories currently installed.)\r\nPreparing to unpack .../00-perl-modules-5.28_5.28.1-6_all.deb ...\r\nUnpacking perl-modules-5.28 (5.28.1-6) ...\r\nSelecting previously unselected package libgdbm6:amd64.\r\nPreparing to unpack .../01-libgdbm6_1.18.1-4_amd64.deb ...\r\nUnpacking libgdbm6:amd64 (1.18.1-4) ...\r\nSelecting previously unselected package libgdbm-compat4:amd64.\r\nPreparing to unpack .../02-libgdbm-compat4_1.18.1-4_amd64.deb ...\r\nUnpacking libgdbm-compat4:amd64 (1.18.1-4) ...\r\nSelecting previously unselected package libperl5.28:amd64.\r\nPreparing to unpack .../03-libperl5.28_5.28.1-6_amd64.deb ...\r\nUnpacking libperl5.28:amd64 (5.28.1-6) ...\r\nSelecting previously unselected package perl.\r\nPreparing to unpack .../04-perl_5.28.1-6_amd64.deb ...\r\nUnpacking perl (5.28.1-6) ...\r\nSelecting previously unselected package libev4:amd64.\r\nPreparing to unpack .../05-libev4_1%3a4.25-1_amd64.deb ...\r\nUnpacking libev4:amd64 (1:4.25-1) ...\r\nSelecting previously unselected package libfsplib0.\r\nPreparing to unpack .../06-libfsplib0_0.11-2_amd64.deb ...\r\nUnpacking libfsplib0 (0.11-2) ...\r\nSelecting previously unselected package libgpm2:amd64.\r\nPreparing to unpack .../07-libgpm2_1.20.7-5_amd64.deb ...\r\nUnpacking libgpm2:amd64 (1.20.7-5) ...\r\nSelecting previously unselected package liblua5.1-0:amd64.\r\nPreparing to unpack .../08-liblua5.1-0_5.1.5-8.1+b2_amd64.deb ...\r\nUnpacking liblua5.1-0:amd64 (5.1.5-8.1+b2) ...\r\nSelecting previously unselected package libtre5:amd64.\r\nPreparing to unpack .../09-libtre5_0.8.0-6_amd64.deb ...\r\nUnpacking libtre5:amd64 (0.8.0-6) ...\r\nSelecting previously unselected package elinks-data.\r\nPreparing to unpack .../10-elinks-data_0.13~20190125-3_all.deb ...\r\nUnpacking elinks-data (0.13~20190125-3) ...\r\nSelecting previously unselected package elinks.\r\nPreparing to unpack .../11-elinks_0.13~20190125-3_amd64.deb ...\r\nUnpacking elinks (0.13~20190125-3) ...\r\nSetting up perl-modules-5.28 (5.28.1-6) ...\r\nSetting up libtre5:amd64 (0.8.0-6) ...\r\nSetting up elinks-data (0.13~20190125-3) ...\r\nSetting up libgpm2:amd64 (1.20.7-5) ...\r\nSetting up libev4:amd64 (1:4.25-1) ...\r\nSetting up libfsplib0 (0.11-2) ...\r\nSetting up liblua5.1-0:amd64 (5.1.5-8.1+b2) ...\r\nSetting up libgdbm6:amd64 (1.18.1-4) ...\r\nSetting up libgdbm-compat4:amd64 (1.18.1-4) ...\r\nSetting up libperl5.28:amd64 (5.28.1-6) ...\r\nSetting up elinks (0.13~20190125-3) ...\r\nSetting up perl (5.28.1-6) ...\r\nProcessing triggers for libc-bin (2.28-10) ...\r\nProcessing triggers for mime-support (3.62) ...\r\n", "stdout_lines": [ "Reading package lists...", "Building dependency tree...", "Reading state information...", "The following additional packages will be installed:", " elinks-data libev4 libfsplib0 libgdbm-compat4 libgdbm6 libgpm2 liblua5.1-0", " libperl5.28 libtre5 perl perl-modules-5.28", "Suggested packages:", " elinks-doc gpm tre-agrep perl-doc libterm-readline-gnu-perl", " | libterm-readline-perl-perl make libb-debug-perl liblocale-codes-perl", "The following NEW packages will be installed:", " elinks elinks-data libev4 libfsplib0 libgdbm-compat4 libgdbm6 libgpm2", " liblua5.1-0 libperl5.28 libtre5 perl perl-modules-5.28", "0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.", "Need to get 8319 kB of archives.", "After this operation, 51.3 MB of additional disk space will be used.", "Get:1 http://mirror.aminidc.com/debian buster/main amd64 perl-modules-5.28 all 5.28.1-6 [2873 kB]", "Get:2 http://mirror.aminidc.com/debian buster/main amd64 libgdbm6 amd64 1.18.1-4 [64.7 kB]", "Get:3 http://mirror.aminidc.com/debian buster/main amd64 libgdbm-compat4 amd64 1.18.1-4 [44.1 kB]", "Get:4 http://mirror.aminidc.com/debian buster/main amd64 libperl5.28 amd64 5.28.1-6 [3883 kB]", "Get:5 http://mirror.aminidc.com/debian buster/main amd64 perl amd64 5.28.1-6 [204 kB]", "Get:6 http://mirror.aminidc.com/debian buster/main amd64 libev4 amd64 1:4.25-1 [39.0 kB]", "Get:7 http://mirror.aminidc.com/debian buster/main amd64 libfsplib0 amd64 0.11-2 [14.6 kB]", "Get:8 http://mirror.aminidc.com/debian buster/main amd64 libgpm2 amd64 1.20.7-5 [35.1 kB]", "Get:9 http://mirror.aminidc.com/debian buster/main amd64 liblua5.1-0 amd64 5.1.5-8.1+b2 [111 kB]", "Get:10 http://mirror.aminidc.com/debian buster/main amd64 libtre5 amd64 0.8.0-6 [58.5 kB]", "Get:11 http://mirror.aminidc.com/debian buster/main amd64 elinks-data all 0.13~20190125-3 [383 kB]", "Get:12 http://mirror.aminidc.com/debian buster/main amd64 elinks amd64 0.13~20190125-3 [608 kB]", "Fetched 8319 kB in 32s (256 kB/s)", "Selecting previously unselected package perl-modules-5.28.", "(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 ... 35146 files and directories currently installed.)", "Preparing to unpack .../00-perl-modules-5.28_5.28.1-6_all.deb ...", "Unpacking perl-modules-5.28 (5.28.1-6) ...", "Selecting previously unselected package libgdbm6:amd64.", "Preparing to unpack .../01-libgdbm6_1.18.1-4_amd64.deb ...", "Unpacking libgdbm6:amd64 (1.18.1-4) ...", "Selecting previously unselected package libgdbm-compat4:amd64.", "Preparing to unpack .../02-libgdbm-compat4_1.18.1-4_amd64.deb ...", "Unpacking libgdbm-compat4:amd64 (1.18.1-4) ...", "Selecting previously unselected package libperl5.28:amd64.", "Preparing to unpack .../03-libperl5.28_5.28.1-6_amd64.deb ...", "Unpacking libperl5.28:amd64 (5.28.1-6) ...", "Selecting previously unselected package perl.", "Preparing to unpack .../04-perl_5.28.1-6_amd64.deb ...", "Unpacking perl (5.28.1-6) ...", "Selecting previously unselected package libev4:amd64.", "Preparing to unpack .../05-libev4_1%3a4.25-1_amd64.deb ...", "Unpacking libev4:amd64 (1:4.25-1) ...", "Selecting previously unselected package libfsplib0.", "Preparing to unpack .../06-libfsplib0_0.11-2_amd64.deb ...", "Unpacking libfsplib0 (0.11-2) ...", "Selecting previously unselected package libgpm2:amd64.", "Preparing to unpack .../07-libgpm2_1.20.7-5_amd64.deb ...", "Unpacking libgpm2:amd64 (1.20.7-5) ...", "Selecting previously unselected package liblua5.1-0:amd64.", "Preparing to unpack .../08-liblua5.1-0_5.1.5-8.1+b2_amd64.deb ...", "Unpacking liblua5.1-0:amd64 (5.1.5-8.1+b2) ...", "Selecting previously unselected package libtre5:amd64.", "Preparing to unpack .../09-libtre5_0.8.0-6_amd64.deb ...", "Unpacking libtre5:amd64 (0.8.0-6) ...", "Selecting previously unselected package elinks-data.", "Preparing to unpack .../10-elinks-data_0.13~20190125-3_all.deb ...", "Unpacking elinks-data (0.13~20190125-3) ...", "Selecting previously unselected package elinks.", "Preparing to unpack .../11-elinks_0.13~20190125-3_amd64.deb ...", "Unpacking elinks (0.13~20190125-3) ...", "Setting up perl-modules-5.28 (5.28.1-6) ...", "Setting up libtre5:amd64 (0.8.0-6) ...", "Setting up elinks-data (0.13~20190125-3) ...", "Setting up libgpm2:amd64 (1.20.7-5) ...", "Setting up libev4:amd64 (1:4.25-1) ...", "Setting up libfsplib0 (0.11-2) ...", "Setting up liblua5.1-0:amd64 (5.1.5-8.1+b2) ...", "Setting up libgdbm6:amd64 (1.18.1-4) ...", "Setting up libgdbm-compat4:amd64 (1.18.1-4) ...", "Setting up libperl5.28:amd64 (5.28.1-6) ...", "Setting up elinks (0.13~20190125-3) ...", "Setting up perl (5.28.1-6) ...", "Processing triggers for libc-bin (2.28-10) ...", "Processing triggers for mime-support (3.62) ..." ] } |
- به عنوان مثال دستور زیر باعث میشود تا :
- بستهی elinks بر روی گروهی خاص از خادمهای تحت مدیریت پاک شود.
|
1 |
# ansible -i hosts.list debian-servers -m <span style="color: #ff0000;">apt</span> -a "<span style="color: #ff0000;">name=elinks state=absent</span>" |
- در صورتی که دستور بالا به صورت موفقیت آمیز اجرا شده باشد، خروجیای مشابه زیر دریافت خواهید کرد :
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
172.16.0.247 | SUCCESS => { "changed": true, "stderr": "", "stderr_lines": [], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following packages were automatically installed and are no longer required:\n elinks-data libev4 libfsplib0 liblua5.1-0 libtre5\nUse 'apt autoremove' to remove them.\nThe following packages will be REMOVED:\n elinks\n0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.\nAfter this operation, 1794 kB 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 ... 37223 files and directories currently installed.)\r\nRemoving elinks (0.13~20190125-3) ...\r\nProcessing triggers for mime-support (3.62) ...\r\n", "stdout_lines": [ "Reading package lists...", "Building dependency tree...", "Reading state information...", "The following packages were automatically installed and are no longer required:", " elinks-data libev4 libfsplib0 liblua5.1-0 libtre5", "Use 'apt autoremove' to remove them.", "The following packages will be REMOVED:", " elinks", "0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.", "After this operation, 1794 kB 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 ... 37223 files and directories currently installed.)", "Removing elinks (0.13~20190125-3) ...", "Processing triggers for mime-support (3.62) ..." ] } |
- دستور بالا معادل دستور apt-get remove عمل میکند یعنی به صورت کامل و جامع اقدام به پاک کردن ابزار نمیکند.
- به عنوان مثال دستور زیر باعث می شود تا :
- بستهی apache2 به صورت جامع و کامل از روی گروهی خاص از خادمهای تحت مدیریت پاک شود.
|
1 |
# ansible -i hosts.list debian-servers -m <span style="color: #ff0000;">apt</span> -a "<span style="color: #ff0000;">name=apache2 purge=yes state=absent</span>" |
- در صورتی که دستور بالا به صورت موفقیت آمیز اجرا شده باشد، خروجیای مشابه زیر دریافت خواهید کرد :
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
172.16.0.247 | SUCCESS => { "changed": true, "stderr": "", "stderr_lines": [], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following packages were automatically installed and are no longer required:\n apache2-bin apache2-data apache2-utils elinks-data libapr1 libaprutil1\n libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4 libev4\n libfsplib0 libjansson4 liblua5.1-0 liblua5.2-0 libtre5 ssl-cert\nUse 'apt autoremove' to remove them.\nThe following packages will be REMOVED:\n apache2*\n0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.\nAfter this operation, 0 B of additional disk space will be used.\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 ... 37911 files and directories currently installed.)\r\nPurging configuration files for apache2 (2.4.38-3+deb10u3) ...\r\nProcessing triggers for systemd (241-7~deb10u3) ...\r\n", "stdout_lines": [ "Reading package lists...", "Building dependency tree...", "Reading state information...", "The following packages were automatically installed and are no longer required:", " apache2-bin apache2-data apache2-utils elinks-data libapr1 libaprutil1", " libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4 libev4", " libfsplib0 libjansson4 liblua5.1-0 liblua5.2-0 libtre5 ssl-cert", "Use 'apt autoremove' to remove them.", "The following packages will be REMOVED:", " apache2*", "0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.", "After this operation, 0 B of additional disk space will be used.", "(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 ... 37911 files and directories currently installed.)", "Purging configuration files for apache2 (2.4.38-3+deb10u3) ...", "Processing triggers for systemd (241-7~deb10u3) ..." ] } |
- دستور بالا معادل دستور apt-get purge میباشد یعنی به صورت کامل و جامع اقدام به پاک کردن ابزار میکند.
- نکته: همان طور که قبلا گفته شد، پارامتر purge و مقدار کلیدی yes باعث پاک شدن کامل بسته میشود.
- به عنوان مثال دستور زیر باعث می شود تا :
- بستههای موجود بر روی خادمهای تحت مدیریت ، بروز رسانی شوند.
|
1 |
# ansible -i hosts.list debian-servers -m <span style="color: #ff0000;">apt</span> -a "<span style="color: #ff0000;">update_cache=yes upgrade=dist</span>" |
- در صورتی که دستور بالا به صورت موفقیت آمیز اجرا شده باشد، خروجیای مشابه زیر دریافت خواهید کرد :
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
172.16.0.247 | SUCCESS => { "changed": false, "msg": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nCalculating upgrade...\nThe following packages were automatically installed and are no longer required:\n apache2-bin apache2-data apache2-utils elinks-data libapr1 libaprutil1\n libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4 libev4\n libfsplib0 libjansson4 liblua5.1-0 liblua5.2-0 libtre5 ssl-cert\nUse 'apt autoremove' to remove them.\n0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\n", "stderr": "", "stderr_lines": [], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nCalculating upgrade...\nThe following packages were automatically installed and are no longer required:\n apache2-bin apache2-data apache2-utils elinks-data libapr1 libaprutil1\n libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4 libev4\n libfsplib0 libjansson4 liblua5.1-0 liblua5.2-0 libtre5 ssl-cert\nUse 'apt autoremove' to remove them.\n0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\n", "stdout_lines": [ "Reading package lists...", "Building dependency tree...", "Reading state information...", "Calculating upgrade...", "The following packages were automatically installed and are no longer required:", " apache2-bin apache2-data apache2-utils elinks-data libapr1 libaprutil1", " libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4 libev4", " libfsplib0 libjansson4 liblua5.1-0 liblua5.2-0 libtre5 ssl-cert", "Use 'apt autoremove' to remove them.", "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." ] } |
- نکته: لطفا به پارامترهای update_cache ، upgrade و مقدار کلیدی آنها توجه کنید.
- نکته: دستور بالا معادل دستور زیر عمل میکند :
|
1 |
apt-get update ; apt-get -y dist-upgrade |
- به عنوان مثال دستور زیر باعث میشود تا :
- بستههای دارای مغایرت و نیازمند حذف ، پاک شوند.
|
1 |
# ansible -i hosts.list debian-servers -m <span style="color: #ff0000;">apt</span> -a "<span style="color: #ff0000;">autoremove=yes</span>" |
- در صورتی که دستور بالا به صورت موفقیت آمیز اجرا شده باشد، خروجیای مشابه زیر دریافت خواهید کرد :
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
172.16.0.247 | SUCCESS => { "changed": false, "stderr": "", "stderr_lines": [], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following packages will be REMOVED:\n apache2-bin apache2-data apache2-utils elinks-data libapr1 libaprutil1\n libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4 libev4\n libfsplib0 libjansson4 liblua5.1-0 liblua5.2-0 libtre5 ssl-cert\n0 upgraded, 0 newly installed, 17 to remove and 0 not upgraded.\nAfter this operation, 11.5 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 ... 37745 files and directories currently installed.)\r\nRemoving apache2-bin (2.4.38-3+deb10u3) ...\r\nRemoving apache2-data (2.4.38-3+deb10u3) ...\r\nRemoving apache2-utils (2.4.38-3+deb10u3) ...\r\nRemoving elinks-data (0.13~20190125-3) ...\r\nRemoving libaprutil1-ldap:amd64 (1.6.1-4) ...\r\nRemoving libaprutil1-dbd-sqlite3:amd64 (1.6.1-4) ...\r\nRemoving libaprutil1:amd64 (1.6.1-4) ...\r\nRemoving libapr1:amd64 (1.6.5-1+b1) ...\r\nRemoving libbrotli1:amd64 (1.0.7-2) ...\r\nRemoving libcurl4:amd64 (7.64.0-4+deb10u1) ...\r\nRemoving libev4:amd64 (1:4.25-1) ...\r\nRemoving libfsplib0 (0.11-2) ...\r\nRemoving libjansson4:amd64 (2.12-1) ...\r\nRemoving liblua5.1-0:amd64 (5.1.5-8.1+b2) ...\r\nRemoving liblua5.2-0:amd64 (5.2.4-1.1+b2) ...\r\nRemoving libtre5:amd64 (0.8.0-6) ...\r\nRemoving ssl-cert (1.0.39) ...\r\nProcessing triggers for libc-bin (2.28-10) ...\r\n", "stdout_lines": [ "Reading package lists...", "Building dependency tree...", "Reading state information...", "The following packages will be REMOVED:", " apache2-bin apache2-data apache2-utils elinks-data libapr1 libaprutil1", " libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4 libev4", " libfsplib0 libjansson4 liblua5.1-0 liblua5.2-0 libtre5 ssl-cert", "0 upgraded, 0 newly installed, 17 to remove and 0 not upgraded.", "After this operation, 11.5 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 ... 37745 files and directories currently installed.)", "Removing apache2-bin (2.4.38-3+deb10u3) ...", "Removing apache2-data (2.4.38-3+deb10u3) ...", "Removing apache2-utils (2.4.38-3+deb10u3) ...", "Removing elinks-data (0.13~20190125-3) ...", "Removing libaprutil1-ldap:amd64 (1.6.1-4) ...", "Removing libaprutil1-dbd-sqlite3:amd64 (1.6.1-4) ...", "Removing libaprutil1:amd64 (1.6.1-4) ...", "Removing libapr1:amd64 (1.6.5-1+b1) ...", "Removing libbrotli1:amd64 (1.0.7-2) ...", "Removing libcurl4:amd64 (7.64.0-4+deb10u1) ...", "Removing libev4:amd64 (1:4.25-1) ...", "Removing libfsplib0 (0.11-2) ...", "Removing libjansson4:amd64 (2.12-1) ...", "Removing liblua5.1-0:amd64 (5.1.5-8.1+b2) ...", "Removing liblua5.2-0:amd64 (5.2.4-1.1+b2) ...", "Removing libtre5:amd64 (0.8.0-6) ...", "Removing ssl-cert (1.0.39) ...", "Processing triggers for libc-bin (2.28-10) ..." ] } |
- نکته: لطفا به پارامتر autoremove و مقدار کلیدی آن در دستور بالا آن توجه کنید.
- برای مطالعه بیشتر در خصوص این ماژول به آدرس اینترنتی زیر مراجعه کنید :
|
1 |
https://docs.ansible.com/ansible/latest/modules/apt_module.html |
- همچنین برای مطالعه بییشتر در خصوص این ماژول، میتوان از دستور ansible-doc استفاده نمود.
- آزمایش شده بر روی Ansible نسخهی 2.5.1
- آزمایش شده بر روی سیستم عامل Ubuntu 18.04