# sshd\_config or a banner file

**URL:** <https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570>\
**Category:** Ansible Project\
**Created:** [May 23, 2012, 9:48pm UTC](https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570 "2012-05-23T21:48:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [May 23, 2012, 9:48pm UTC](https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570/1 "2012-05-23T21:48:46Z")

</div>

Hi,  
Today I'm making another go at Ansible. Part of using Ansible is  
getting rid of some of the bad decisions the previous administrators  
did in the name of "security".

I want to deploy a standard sshd\_config file and a /etc/banner

Do I need to create a j2 file to start this process? I'm not setting  
a static IP for sshd to listen on, so I don't think I have any  
variables. The banner file should be on all machines.

James

---

<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:** [May 23, 2012, 9:50pm UTC](https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570/2 "2012-05-23T21:50:35Z")

</div>

Yeah, it’s not required.

You can use the ‘copy’ module instead of the ‘template’ module if you just want to transfer the file directly without any changes.

It works basically the same, without doing any template ops, and you can still specify the mode, user, and other things, just like you can with the file module (and the template module).

–Michael

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [May 30, 2012, 3:26am UTC](https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570/3 "2012-05-30T03:26:48Z")

</div>

If the destination file does not exist, do we need to use an option to  
state=? I have tried my command with and without state=absent. When I  
run it with state=absent I get: 10.54.244.155 | success \>\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"changed": true,  
&nbsp;&nbsp;&nbsp;&nbsp;"md5sum": "75e1e5d01516c1218752b3238f84b3e7",  
&nbsp;&nbsp;&nbsp;&nbsp;"path": "/etc/banner",  
&nbsp;&nbsp;&nbsp;&nbsp;"state": "absent"

Either way my file doesn't get copied.

Here is the command I used:

ansible CL800Internal -m copy -a  
"src=/Users/jmarcus/AnsibleFiles/etc/banner dest=/etc/banner  
state=absent" -u jmarcus --ask-sudo-pass

thanks,  
James

---

<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:** [May 30, 2012, 12:27pm UTC](https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570/4 "2012-05-30T12:27:57Z")

</div>

--Michael

> If the destination file does not exist, do we need to use an option to  
> state=? I have tried my command with and without state=absent. When I

Leaving off state= implies 'present'.

> run it with state=absent I get: 10.54.244.155 | success \>\> {  
> "changed": true,  
> "md5sum": "75e1e5d01516c1218752b3238f84b3e7",  
> "path": "/etc/banner",  
> "state": "absent"
> 
> Either way my file doesn't get copied.

If you are using the file module with state=absent, you are actually asking for the file to be removed.

The copy module actually calls the file module after doing it's thing.

You can leave off the "state=" or put in "state=present", both mean the same thing.

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [May 30, 2012, 12:33pm UTC](https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570/5 "2012-05-30T12:33:42Z")

</div>

Hi,  
So what am I missing?, in the documentation this command seems to say  
I can copy a file to multiple servers: ansible atlanta -m copy -a  
"src=/etc/hosts dest=/tmp/hosts".

Thanks,  
James

---

<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:** [May 30, 2012, 12:37pm UTC](https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570/6 "2012-05-30T12:37:25Z")

</div>

--Michael

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [May 30, 2012, 1:31pm UTC](https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570/7 "2012-05-30T13:31:28Z")

</div>

I ran this command:  
sheepchase:~ jmarcus$ ansible CL800 -m copy -a  
"src=/Users/jmarcus/AnsibleFiles/etc/banner dest=/etc/banner" -u  
jmarcus --ask-sudo-pass

I got this output for all the servers in group, I guess I'm confused  
because I think I'm using "copy" correctly.

cl806.DOMAIN.net | FAILED \>\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"changed": true,  
&nbsp;&nbsp;&nbsp;&nbsp;"failed": true,  
&nbsp;&nbsp;&nbsp;&nbsp;"md5sum": "75e1e5d01516c1218752b3238f84b3e7",  
&nbsp;&nbsp;&nbsp;&nbsp;"msg": "file does not exist, use copy or template module to create",  
&nbsp;&nbsp;&nbsp;&nbsp;"path": "/etc/banner",  
&nbsp;&nbsp;&nbsp;&nbsp;"state": "absent"  
}

Thanks,  
James

---

<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:** [May 30, 2012, 1:36pm UTC](https://forum.ansible.com/t/sshd-config-or-a-banner-file/11570/8 "2012-05-30T13:36:39Z")

</div>

Interesting. It seems like the copy module is not failing and then the file module is yelling at you because the copy module didn’t place it down.

It might be a permissions error of some kind that is not being handled.

The best thing you can do is add debug to the execute\_copy function in runner/ **init**.py and  
see what’s up.
