# New user comments

**URL:** <https://forum.ansible.com/t/new-user-comments/11985>\
**Category:** Ansible Project\
**Created:** [October 16, 2012, 4:17pm UTC](https://forum.ansible.com/t/new-user-comments/11985 "2012-10-16T16:17:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://forum.ansible.com/u/Brian_Candler)\
**Post date:** [October 16, 2012, 4:17pm UTC](https://forum.ansible.com/t/new-user-comments/11985/1 "2012-10-16T16:17:22Z")

</div>

Just done my first ansible deployment today; very impressive how easy it is to get up and running! Thank you for releasing it.

I have a few bits of feedback and questions.

1. lineinfile regexp appears to be anchored, i.e. you need to do

lineinfile regexp=“.\*foo”

to match foo other than at start of line. I’m not sure if this is intentional, since the docs show examples like regexp=^SELINUX= (explicitly anchoring the line)

My guess is this is an artefact of using Python’s re.match instead of re.search.

> > > re.match(“b”,“abc”)

> > > re.match(“.\*b”,“abc”)  
> > > \<\_sre.SRE\_Match object at 0x1005a9f38\>

> > > re.search(“b”,“abc”)  
> > > \<\_sre.SRE\_Match object at 0x1005a9ed0\>

1. Wishlist: it would be nice to have playbook action as an array, to save having to name every single micro step:

- name: install some packages  
action:
- apt pkg=snmpd state=latest
- apt pkg=snmp-mibs-downloader state=latest
- …

(however, the ‘with\_items’ syntax can be used in that particular case)

1. What’s the recommended way of dealing with a tree of files? The best I can come up with so far is to list them one by one with ‘with\_items’

- name: add SNMP files  
action: copy src=snmp-files$item dest=$item mode=644

with\_items:

- /usr/share/snmp/mibs/MD-RAID-MIB.txt
- /usr/share/snmp/mibs/HACKING-SNMP-MIB.txt
- /usr/share/snmp/mibs/SMARTCTL-MIB.txt
- /usr/lib/snmpd-connector-lib.sh
- /usr/lib/hacking-bash.sh

Have I missed a trick here?

One solution would be a construct like with\_items which recursively iterates over a source directory, which would be simple to implement, albeit slow.

A faster solution would be for the copy/template module to work recursively, check all the md5sums in one go, and upload all the changes files in one go; but I suspect that would be quite a lot more work.

1. Any suggestions for how to say “ensure this directory is empty apart from the files I just installed”? Usage case is /etc/freeradius where there’s a load of default junk installed by the package manager, which I want to remove. Of course I can just remove it entirely (state=absent) and then install the files I want, but that is an operation I would not want to run repeatedly.

Thanks again,

Brian.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [October 16, 2012, 5:59pm UTC](https://forum.ansible.com/t/new-user-comments/11985/2 "2012-10-16T17:59:45Z")

</div>

Replies inline.

> Just done my first ansible deployment today; very impressive how easy it is  
> to get up and running! Thank you for releasing it.
> 
> I have a few bits of feedback and questions.
> 
> 1. lineinfile regexp appears to be anchored, i.e. you need to do
> 
> lineinfile regexp=".\*foo"

In 0.8, it is no longer anchored -- and that's been true for a while.  
It releases Friday.

> 2. Wishlist: it would be nice to have playbook action as an array, to save  
> having to name every single micro step:
> 
> - name: install some packages  
> &nbsp;&nbsp;action:  
> &nbsp;&nbsp;- apt pkg=snmpd state=latest  
> &nbsp;&nbsp;- apt pkg=snmp-mibs-downloader state=latest

This is not going to happen, but "name" is optional, so just don't  
specify the name.

> &nbsp;&nbsp;- ...
> 
> (however, the 'with\_items' syntax can be used in that particular case)
> 
> 3. What's the recommended way of dealing with a tree of files? The best I  
> can come up with so far is to list them one by one with 'with\_items'

This, in 0.8

[https://github.com/ansible/ansible/blob/devel/examples/playbooks/loop\_plugins.yml](https://github.com/ansible/ansible/blob/devel/examples/playbooks/loop_plugins.yml)

(or just use local\_action with rsync if you need recursion)

> 4. Any suggestions for how to say "ensure this directory is empty apart from  
> the files I just installed"? Usage case is /etc/freeradius where there's a  
> load of default junk installed by the package manager, which I want to  
> remove. Of course I can just remove it entirely (state=absent) and then  
> install the files I want, but that is an operation I would not want to run  
> repeatedly.

No method for this exists, or will exist. Sorry.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://forum.ansible.com/u/Brian_Candler)\
**Post date:** [October 16, 2012, 10:46pm UTC](https://forum.ansible.com/t/new-user-comments/11985/3 "2012-10-16T22:46:04Z")

</div>

Thanks for your quick reply.

> In 0.8, it is no longer anchored – and that’s been true for a while.  
> It releases Friday.

Great. (BTW I am using 0.7.2 from apt repo)

> > 1. Wishlist: it would be nice to have playbook action as an array, to save  
> > having to name every single micro step:
> > 
> > - name: install some packages  
> > action:
> > - apt pkg=snmpd state=latest
> > - apt pkg=snmp-mibs-downloader state=latest
> 
> This is not going to happen, but “name” is optional, so just don’t  
> specify the name.

I see. The example you linked seems to use another syntax as well:

```auto

 tasks:
    - file: dest=/etc/fooapp state=directory

    - copy: src=$item dest=/etc/fooapp/ owner=root mode=600

      with_fileglob: /playbooks/files/fooapp/* 

```

which is slightly briefer than

- action: file dest=/etc/fooapp state=directory
- action: copy src=$item dest=/etc/fooapp/ owner=root mode=600

Cheers,

Brian.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://forum.ansible.com/u/Brian_Candler)\
**Post date:** [October 16, 2012, 10:46pm UTC](https://forum.ansible.com/t/new-user-comments/11985/4 "2012-10-16T22:46:11Z")

</div>

Thanks for your quick reply.

> In 0.8, it is no longer anchored – and that’s been true for a while.  
> It releases Friday.

Great. (BTW I am using 0.7.2 from apt repo)

> > 1. Wishlist: it would be nice to have playbook action as an array, to save  
> > having to name every single micro step:
> > 
> > - name: install some packages  
> > action:
> > - apt pkg=snmpd state=latest
> > - apt pkg=snmp-mibs-downloader state=latest
> 
> This is not going to happen, but “name” is optional, so just don’t  
> specify the name.

I see. The example you linked seems to use another syntax as well:

```auto

 tasks:
    - file: dest=/etc/fooapp state=directory

    - copy: src=$item dest=/etc/fooapp/ owner=root mode=600

      with_fileglob: /playbooks/files/fooapp/* 

```

which is slightly briefer than

- action: file dest=/etc/fooapp state=directory
- action: copy src=$item dest=/etc/fooapp/ owner=root mode=600

Cheers,

Brian.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [October 17, 2012, 5:57am UTC](https://forum.ansible.com/t/new-user-comments/11985/5 "2012-10-17T05:57:16Z")

</div>

This is a new shortcut syntax, which was introduced last week or so.

Serge
