# Specifying version when installing Apache

**URL:** <https://forum.ansible.com/t/specifying-version-when-installing-apache/24165>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [April 6, 2017, 8:06pm UTC](https://forum.ansible.com/t/specifying-version-when-installing-apache/24165 "2017-04-06T20:06:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_F](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@Dan\_F](https://forum.ansible.com/u/Dan_F)\
**Post date:** [April 6, 2017, 8:06pm UTC](https://forum.ansible.com/t/specifying-version-when-installing-apache/24165/1 "2017-04-06T20:06:07Z")

</div>

I’m thinking of using specific versions for everything whenever I can. This would enable me to mirror exactly what I have in one server to another at any given time.

With that said, I tried a very basic install of Apache and attempted to see what it took to get this configured.

I started with:

tasks:

- name: install apache2  
apt: name=apache2 state=installed update\_cache=yes  
notify: start apache2

Then, to see the version installed:

me@server:~$ apache2 -v  
Server version: Apache/2.4.18 (Ubuntu)  
Server built: 2016-07-14T12:32:26

I figure, I should just specify the version in my playbook:

tasks:

- name: install apache2  
apt: name=apache2=2.4.18 state=installed update\_cache=yes  
notify: start apache2

The error when I run the playbook:

TASK [install apache2] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [192.168.2.33]: FAILED! =\> {“cache\_update\_time”: 1491508623, “cache\_updated”: true, “changed”: false, “failed”: true, “msg”: “‘/usr/bin/apt-get -y -o "Dpkg::Options::=–force-confdef" -o "Dpkg::Options::=–force-confold" install ‘apache2=2.4.18’’ failed: E: Version ‘2.4.18’ for ‘apache2’ was not found\n”, “stderr”: “E: Version ‘2.4.18’ for ‘apache2’ was not found\n”, “stdout”: “Reading package lists…\nBuilding dependency tree…\nReading state information…\n”, “stdout\_lines”: [“Reading package lists…”, “Building dependency tree…”, “Reading state information…”]}

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 7, 2017, 5:56am UTC](https://forum.ansible.com/t/specifying-version-when-installing-apache/24165/2 "2017-04-07T05:56:51Z")

</div>

If you run a "apt-cache show apache2 | grep Version" you'll see that the version is longer, something like "2.4.18-2ubuntu3.1"

You'll need to specify the entire string or use wildcard, read more about wildcard in the comments to name here  
[https://docs.ansible.com/ansible/apt\_module.html#options](https://docs.ansible.com/ansible/apt_module.html#options)
