# Noob question about time to run playbook.

**URL:** <https://forum.ansible.com/t/noob-question-about-time-to-run-playbook/37042>\
**Category:** Ansible Project\
**Created:** [August 27, 2022, 9:01pm UTC](https://forum.ansible.com/t/noob-question-about-time-to-run-playbook/37042 "2022-08-27T21:01:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Shumaker](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@Kevin\_Shumaker](https://forum.ansible.com/u/Kevin_Shumaker)\
**Post date:** [August 27, 2022, 9:01pm UTC](https://forum.ansible.com/t/noob-question-about-time-to-run-playbook/37042/1 "2022-08-27T21:01:28Z")

</div>

Greetings all. I’d like to tap your knowledge to see if there is a way to tweak a playbook to ‘speed things up’. I have a list of apps that always get installed to a new server. If I do them manually, as either a single command:

apt install sendemail libio-socket-ssl-perl libnet-ssleay-perl perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions dos2unix samba ntfs-3g gcc make git-core neofetch net-tools curl chrony linux-headers-$(uname -r) conky python3-pip -y  
or individually  
apt install app1  
apt install app2  
…  
or as a bash script

it takes 5-7 minutes.  
But if I run the install as a vars list using:

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [August 29, 2022, 1:40pm UTC](https://forum.ansible.com/t/noob-question-about-time-to-run-playbook/37042/2 "2022-08-29T13:40:49Z")

</div>

Your last apt task … does it need a ‘state: present’ parameter?

> - name: install standard stuff  
> apt:  
> name: “{{ applications }}”

> **state: present**

Do you support other families of Linux? If so you may want to consider storing your vars in family-specific vars files and including them based on ansible\_os\_family, and use the package module vs apt/yum modules. Something like this.

vars\_files:

- “./common/{{ ansible\_os\_family }}.yml”  
tasks:
- name: install required packages  
package:  
name: “{{ applications }}”  
state: present
- name: update all packages  
package:  
name: \*  
state: latest

All these “family” vars files could define the same vars, but each var would have os family specific values such as package names. You use these common vars in your tasks, but the tasks then become OS agnostic because you sourced an OS family specific vars file. In some cases you may need an os distribution and version.

vars\_files:

- “./common/{{ (ansible\_distribution|lower) + ansible\_distribution\_major\_version }}.yml”

tasks:

- name: install required packages  
package:  
name: “{{ applications }}”  
state: present
- name: update all packages  
package:  
name: \*  
state: latest

This would look for files like redhat8.yml, ubuntu22.yml, debian10.yml, amazon2.yml, etc.

I reference a folder called ‘./common’ but you can place them anywhere you like.

Just some thoughts on making playbooks and tasks more future proof …

Walter

---

<div class="post-metadata">

**Author:** ![Kevin\_Shumaker](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@Kevin\_Shumaker](https://forum.ansible.com/u/Kevin_Shumaker)\
**Post date:** [August 29, 2022, 2:02pm UTC](https://forum.ansible.com/t/noob-question-about-time-to-run-playbook/37042/3 "2022-08-29T14:02:42Z")

</div>

Many thanks for rapid responses.

re: need of a ‘state: present’ parameter

- It does not seem to need that line, and even if included, does not make a difference in the amount of time taken.  
re: vars files vs vars in playbook
- I have not been able to resolve issues with using any version of a vars.yml file to separate out that information. I currently only support Debian based (Debian / RaspberryPiOS / Ubuntu) Linuxes with ansible. After (If?) I get this working, then I will try expanding to other options. Trying this one step at a time.

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [August 29, 2022, 2:09pm UTC](https://forum.ansible.com/t/noob-question-about-time-to-run-playbook/37042/4 "2022-08-29T14:09:18Z")

</div>

vars files look like other yml files.

---

<div class="post-metadata">

**Author:** ![Kevin\_Shumaker](https://avatars.discourse-cdn.com/v4/letter/k/eb9ed0/32.png) [@Kevin\_Shumaker](https://forum.ansible.com/u/Kevin_Shumaker)\
**Post date:** [August 29, 2022, 3:21pm UTC](https://forum.ansible.com/t/noob-question-about-time-to-run-playbook/37042/5 "2022-08-29T15:21:51Z")

</div>

Spaces are everything, Mr Rowe. Thanks for the hint for my vars.yml issue, (application list in a separate vars.yml file) which is now working as expected. Still takes forever (relatively speaking) to install the apps, but It’s helping me make the actual playbook more readable.

I wish there was a better syntax and space checking tool, ansible’s reminds me of the old Linux printer error message: “it’s on fire”…
