debian ansible playbook #1
This commit is contained in:
parent
ddc95abc90
commit
f979d04171
58
content/debian-update-with-ansible.md
Normal file
58
content/debian-update-with-ansible.md
Normal file
@ -0,0 +1,58 @@
|
||||
Title: Update Debian with Ansible
|
||||
Date: 2016-01-31
|
||||
Category: Ansible Playbook
|
||||
|
||||
## Introduction
|
||||
|
||||
I've recently bought a [HP Proliant Microserver Gen8](http://www8.hp.com/us/en/products/proliant-servers/product-detail.html?oid=5379860) to play around with LXC and try new stuff.
|
||||
|
||||
From the 4 Debian machines I had to keep up-to-date, I now have 7, so it became quite time-consumming to manually SSH to each of them whenever an update became available.
|
||||
|
||||
I ended up looking at [Ansible](http://www.ansible.com/) to speed up the process and, within an hour, I had a working playbook that updates the debian packages, pip packages and git repos on all of my servers with a single command.
|
||||
|
||||
I figured I'd share the playbook I use to update the Debian packages !
|
||||
|
||||
## The playbook
|
||||
|
||||
I modified [this gist](https://gist.github.com/maethor/380676f6b1cec8cc7439) to only use apt-get instead of both apt-get and aptitude.
|
||||
|
||||
```yaml
|
||||
- hosts: all
|
||||
remote_user: admin
|
||||
become: yes
|
||||
become_method: sudo
|
||||
tasks:
|
||||
- name: update cache
|
||||
apt: update_cache=yes
|
||||
- name: list packages to upgrade (1/2)
|
||||
shell: apt-get upgrade --show-upgraded --assume-no | grep '^ ' | sed 's/ //;s/ /\n/g'
|
||||
register: updates
|
||||
changed_when: False
|
||||
- name: list packages to upgrade (2/2)
|
||||
debug: msg="{{ updates.stdout_lines | count }} packages to upgrade ({{ updates.stdout_lines | join(', ') }})"
|
||||
when: (updates.stdout_lines)
|
||||
- name: upgrade packages
|
||||
apt: upgrade=dist
|
||||
- name: check what the new version is
|
||||
shell: lsb_release -r | awk '{print $2}'
|
||||
changed_when: False
|
||||
register: new_release
|
||||
- name: notify distribution version upgrade
|
||||
debug: msg="Debian has been upgraded from {{ ansible_lsb.release }} to {{ new_release.stdout }}"
|
||||
when: ansible_lsb.release != new_release.stdout
|
||||
- name: install the debian-goodies package if it is missing
|
||||
apt: name=debian-goodies state=present
|
||||
- name: list services to restart (1/2)
|
||||
shell: checkrestart | grep ^service | awk '{print $2}'
|
||||
register: services
|
||||
changed_when: False
|
||||
- name: list services to restart (2/2)
|
||||
debug: msg="{{ services.stdout_lines | count }} services to restart ({{ services.stdout_lines | join (', ') }})"
|
||||
when: (services.stdout_lines)
|
||||
- name: cache cleanup
|
||||
shell: apt-get autoclean
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
|
||||
That's all ! Please leave a comment if you've found this playbook helpful !
|
@ -89,6 +89,8 @@
|
||||
<dl>
|
||||
<dt>Sun 31 January 2016</dt>
|
||||
<dd><a href="https://captainark.net/private-git-repo.html">Private Git Repo</a></dd>
|
||||
<dt>Sun 31 January 2016</dt>
|
||||
<dd><a href="https://captainark.net/update-debian-with-ansible.html">Update Debian with Ansible</a></dd>
|
||||
<dt>Tue 05 May 2015</dt>
|
||||
<dd><a href="https://captainark.net/flexget-init-script.html">Flexget init script</a></dd>
|
||||
<dt>Fri 24 April 2015</dt>
|
||||
|
@ -99,6 +99,19 @@
|
||||
on Sun 31 January 2016
|
||||
</p>
|
||||
<p>There are <a href="https://captainark.net/private-git-repo.html#disqus_thread">comments</a>.</p> </div>
|
||||
<div class="post-preview">
|
||||
<a href="https://captainark.net/update-debian-with-ansible.html" rel="bookmark" title="Permalink to Update Debian with Ansible">
|
||||
<h2 class="post-title">
|
||||
Update Debian with Ansible
|
||||
</h2>
|
||||
</a>
|
||||
<h2>Introduction</h2>
|
||||
<p>I've recently bought a <a ...
|
||||
<p class="post-meta">Posted by
|
||||
<a href="https://captainark.net/author/antoine-joubert.html">Antoine Joubert</a>
|
||||
on Sun 31 January 2016
|
||||
</p>
|
||||
<p>There are <a href="https://captainark.net/update-debian-with-ansible.html#disqus_thread">comments</a>.</p> </div>
|
||||
<div class="post-preview">
|
||||
<a href="https://captainark.net/flexget-init-script.html" rel="bookmark" title="Permalink to Flexget init script">
|
||||
<h2 class="post-title">
|
||||
|
@ -89,7 +89,7 @@
|
||||
<div class="post-preview">
|
||||
<a href="https://captainark.net/author/antoine-joubert.html" rel="bookmark">
|
||||
<h2 class="post-title">
|
||||
Antoine Joubert (3)
|
||||
Antoine Joubert (4)
|
||||
</h2>
|
||||
</a>
|
||||
</div>
|
||||
|
@ -87,6 +87,7 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<ul>
|
||||
<li><a href="https://captainark.net/category/ansible-playbook.html">Ansible Playbook</a></li>
|
||||
<li><a href="https://captainark.net/category/script.html">Script</a></li>
|
||||
<li><a href="https://captainark.net/category/tutorial.html">Tutorial</a></li>
|
||||
</ul>
|
||||
|
200
output/category/ansible-playbook.html
Normal file
200
output/category/ansible-playbook.html
Normal file
@ -0,0 +1,200 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
|
||||
<title>Sysadmining. All day. Every day. - Articles in the Ansible Playbook category</title>
|
||||
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="https://captainark.net/theme/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link href="https://captainark.net/theme/css/clean-blog.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Code highlight color scheme -->
|
||||
<link href="https://captainark.net/theme/css/code_blocks/github.css" rel="stylesheet">
|
||||
|
||||
|
||||
<!-- Custom Fonts -->
|
||||
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
|
||||
<link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
|
||||
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<meta property="og:locale" content="">
|
||||
<meta property="og:site_name" content="Sysadmining. All day. Every day.">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- Navigation -->
|
||||
<nav class="navbar navbar-default navbar-custom navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header page-scroll">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://captainark.net/">Sysadmining. All day. Every day.</a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><a href="/">Homepage</a></li>
|
||||
<li><a href="/categories.html">Categories</a></li>
|
||||
|
||||
<li><a href="https://captainark.net/pages/about.html">About</a></li>
|
||||
<li><a href="https://captainark.net/pages/resume.html">Resume</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /.navbar-collapse -->
|
||||
</div>
|
||||
<!-- /.container -->
|
||||
</nav>
|
||||
|
||||
<!-- Page Header -->
|
||||
<header class="intro-header" style="background-image: url('/bg.png')">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<div class="post-heading">
|
||||
<h1>Articles in the Ansible Playbook category</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<div class="post-preview">
|
||||
<a href="https://captainark.net/update-debian-with-ansible.html" rel="bookmark" title="Permalink to Update Debian with Ansible">
|
||||
<h2 class="post-title">
|
||||
Update Debian with Ansible
|
||||
</h2>
|
||||
</a>
|
||||
<h2>Introduction</h2>
|
||||
<p>I've recently bought a <a ...
|
||||
<p class="post-meta">Posted by
|
||||
<a href="https://captainark.net/author/antoine-joubert.html">Antoine Joubert</a>
|
||||
on Sun 31 January 2016
|
||||
</p>
|
||||
<p>There are <a href="https://captainark.net/update-debian-with-ansible.html#disqus_thread">comments</a>.</p> </div>
|
||||
|
||||
<hr>
|
||||
<!-- Pager -->
|
||||
<ul class="pager">
|
||||
<li class="next">
|
||||
</li>
|
||||
</ul>
|
||||
Page 1 / 1
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<ul class="list-inline text-center">
|
||||
<li>
|
||||
<a href="mailto:contact@captainark.net">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-envelope fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-github fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://www.last.fm/user/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-lastfm fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://steamcommunity.com/id/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-steam fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://www.twitch.tv/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-twitch fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="copyright text-muted">
|
||||
Blog powered by <a href="http://getpelican.com">Pelican</a>,
|
||||
which takes great advantage of <a href="http://python.org">Python</a>.
|
||||
</p> </div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="https://captainark.net/theme/js/jquery.js"></script>
|
||||
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="https://captainark.net/theme/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Custom Theme JavaScript -->
|
||||
<script src="https://captainark.net/theme/js/clean-blog.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var disqus_shortname = 'captainark';
|
||||
(function () {
|
||||
var s = document.createElement('script'); s.async = true;
|
||||
s.type = 'text/javascript';
|
||||
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
|
||||
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
||||
}());
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -102,6 +102,19 @@
|
||||
on Sun 31 January 2016
|
||||
</p>
|
||||
<p>There are <a href="https://captainark.net/private-git-repo.html#disqus_thread">comments</a>.</p> </div>
|
||||
<div class="post-preview">
|
||||
<a href="https://captainark.net/update-debian-with-ansible.html" rel="bookmark" title="Permalink to Update Debian with Ansible">
|
||||
<h2 class="post-title">
|
||||
Update Debian with Ansible
|
||||
</h2>
|
||||
</a>
|
||||
<h2>Introduction</h2>
|
||||
<p>I've recently bought a <a ...
|
||||
<p class="post-meta">Posted by
|
||||
<a href="https://captainark.net/author/antoine-joubert.html">Antoine Joubert</a>
|
||||
on Sun 31 January 2016
|
||||
</p>
|
||||
<p>There are <a href="https://captainark.net/update-debian-with-ansible.html#disqus_thread">comments</a>.</p> </div>
|
||||
<div class="post-preview">
|
||||
<a href="https://captainark.net/flexget-init-script.html" rel="bookmark" title="Permalink to Flexget init script">
|
||||
<h2 class="post-title">
|
||||
|
267
output/update-debian-with-ansible.html
Normal file
267
output/update-debian-with-ansible.html
Normal file
@ -0,0 +1,267 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
|
||||
<title>Update Debian with Ansible</title>
|
||||
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="https://captainark.net/theme/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link href="https://captainark.net/theme/css/clean-blog.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Code highlight color scheme -->
|
||||
<link href="https://captainark.net/theme/css/code_blocks/github.css" rel="stylesheet">
|
||||
|
||||
|
||||
<!-- Custom Fonts -->
|
||||
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
|
||||
<link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
|
||||
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta property="og:locale" content="">
|
||||
<meta property="og:site_name" content="Sysadmining. All day. Every day.">
|
||||
|
||||
<meta property="og:type" content="article">
|
||||
<meta property="article:author" content="">
|
||||
<meta property="og:url" content="https://captainark.net/update-debian-with-ansible.html">
|
||||
<meta property="og:title" content="Update Debian with Ansible">
|
||||
<meta property="og:description" content="">
|
||||
<meta property="og:image" content="https://captainark.net/">
|
||||
<meta property="article:published_time" content="2016-01-31 00:00:00+01:00">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- Navigation -->
|
||||
<nav class="navbar navbar-default navbar-custom navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header page-scroll">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://captainark.net/">Sysadmining. All day. Every day.</a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><a href="/">Homepage</a></li>
|
||||
<li><a href="/categories.html">Categories</a></li>
|
||||
|
||||
<li><a href="https://captainark.net/pages/about.html">About</a></li>
|
||||
<li><a href="https://captainark.net/pages/resume.html">Resume</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /.navbar-collapse -->
|
||||
</div>
|
||||
<!-- /.container -->
|
||||
</nav>
|
||||
|
||||
<!-- Page Header -->
|
||||
<header class="intro-header" style="background-image: url('/bg.png')">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<div class="post-heading">
|
||||
<h1>Update Debian with Ansible</h1>
|
||||
<span class="meta">Posted by
|
||||
<a href="https://captainark.net/author/antoine-joubert.html">Antoine Joubert</a>
|
||||
on Sun 31 January 2016
|
||||
</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<!-- Post Content -->
|
||||
<article>
|
||||
<h2>Introduction</h2>
|
||||
<p>I've recently bought a <a href="http://www8.hp.com/us/en/products/proliant-servers/product-detail.html?oid=5379860">HP Proliant Microserver Gen8</a> to play around with LXC and try new stuff.</p>
|
||||
<p>From the 4 Debian machines I had to keep up-to-date, I now have 7, so it became quite time-consumming to manually SSH to each of them whenever an update became available.</p>
|
||||
<p>I ended up looking at <a href="http://www.ansible.com/">Ansible</a> to speed up the process and, within an hour, I had a working playbook that updates the debian packages, pip packages and git repos on all of my servers with a single command.</p>
|
||||
<p>I figured I'd share the playbook I use to update the Debian packages !</p>
|
||||
<h2>The playbook</h2>
|
||||
<p>I modified <a href="https://gist.github.com/maethor/380676f6b1cec8cc7439">this gist</a> to only use apt-get instead of both apt-get and aptitude.</p>
|
||||
<div class="highlight"><pre><span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">hosts</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">all</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">remote_user</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">admin</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">become</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">yes</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">become_method</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">sudo</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">tasks</span><span class="p p-Indicator">:</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">update cache</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">apt</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">update_cache=yes</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">list packages to upgrade (1/2)</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">shell</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">apt-get upgrade --show-upgraded --assume-no | grep '^ ' | sed 's/ //;s/ /\n/g'</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">register</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">updates</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">changed_when</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">False</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">list packages to upgrade (2/2)</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">debug</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">msg="{{ updates.stdout_lines | count }} packages to upgrade ({{ updates.stdout_lines | join(', ') }})"</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">when</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">(updates.stdout_lines)</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">upgrade packages</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">apt</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">upgrade=dist</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">check what the new version is</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">shell</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">lsb_release -r | awk '{print $2}'</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">changed_when</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">False</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">register</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">new_release</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">notify distribution version upgrade</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">debug</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">msg="Debian has been upgraded from {{ ansible_lsb.release }} to {{ new_release.stdout }}"</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">when</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">ansible_lsb.release != new_release.stdout</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">install the debian-goodies package if it is missing</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">apt</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">name=debian-goodies state=present</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">list services to restart (1/2)</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">shell</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">checkrestart | grep ^service | awk '{print $2}'</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">register</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">services</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">changed_when</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">False</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">list services to restart (2/2)</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">debug</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">msg="{{ services.stdout_lines | count }} services to restart ({{ services.stdout_lines | join (', ') }})"</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">when</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">(services.stdout_lines)</span>
|
||||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">name</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">cache cleanup</span>
|
||||
<span class="l l-Scalar l-Scalar-Plain">shell</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">apt-get autoclean</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<h2>Conclusion</h2>
|
||||
<p>That's all ! Please leave a comment if you've found this playbook helpful !</p>
|
||||
</article>
|
||||
|
||||
|
||||
<hr>
|
||||
<div class="sharing">
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div class="comments">
|
||||
<h2>Comments !</h2>
|
||||
<div id="disqus_thread"></div>
|
||||
<script type="text/javascript">
|
||||
var disqus_shortname = 'captainark';
|
||||
var disqus_identifier = 'update-debian-with-ansible.html';
|
||||
var disqus_url = 'https://captainark.net/update-debian-with-ansible.html';
|
||||
(function() {
|
||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||
dsq.src = '//captainark.disqus.com/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
})();
|
||||
</script>
|
||||
<noscript>Please enable JavaScript to view the comments.</noscript>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<ul class="list-inline text-center">
|
||||
<li>
|
||||
<a href="mailto:contact@captainark.net">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-envelope fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-github fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://www.last.fm/user/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-lastfm fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://steamcommunity.com/id/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-steam fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://www.twitch.tv/captainark">
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x"></i>
|
||||
<i class="fa fa-twitch fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="copyright text-muted">
|
||||
Blog powered by <a href="http://getpelican.com">Pelican</a>,
|
||||
which takes great advantage of <a href="http://python.org">Python</a>.
|
||||
</p> </div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="https://captainark.net/theme/js/jquery.js"></script>
|
||||
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="https://captainark.net/theme/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Custom Theme JavaScript -->
|
||||
<script src="https://captainark.net/theme/js/clean-blog.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var disqus_shortname = 'captainark';
|
||||
(function () {
|
||||
var s = document.createElement('script'); s.async = true;
|
||||
s.type = 'text/javascript';
|
||||
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
|
||||
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
||||
}());
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user