Assuming it's normal that fdisk/your script returns non-zero, you can
prevent Ansible from treating that as a failure with failed_when
<http://docs.ansible.com/ansible/playbooks_error_handling.html#controlling-what-defines-failure>
...
On Wednesday, April 13, 2016 at 12:03:48 PM UTC-7, richard kappler wrote:
>
> This is a continuation of an earlier thread "Can Ansible interact with an
> Application."
>
> If Edgars is reading, I went a little different route. Parted won't quite
> work as I'm adding two partitions to /dev/sda which already has boot, swap
> and root on it and is mounted. I did some research, and fdisk will do the
> job when run from a script, so I create a script as follows:
>
> #!/bin/bash
>
> echo "u
> c
> n
> p
> 3
>
> +15G
> n
> p
>
>
> w"|fdisk /dev/sda
>
> which creates 2 new partitions, /dev/sda3 from the end of /dev/sda2 at
> 15GB size, then creates /dev/sda4 from the end of /dev/sda3 to the end of
> the drive, and called it Apart.sh
>
> My playbook copies it to /home in the target, makes it executable, then
> runs it.
>
> In testing the script works, it creates the partitions as I expected, when
> I've tested it locally by itself (no Ansible). When Ansible runs it though,
> it crashes:
>
> fatal: [partVSS] : FAILED! => {"changed": true, "cmd": ["/home/Apart.sh"],
> "delta": "0:00:00.034351", "end": "2016-04-13 06:29:35.548649", "failed":
> true, "rc": 1, "start": "2016-04-13 06:29:35.514298",
>
> then it gives me the stderr and stdout outputs.
>
> But it creates the partitions. The script works, even when Ansible runs
> it, but Ansible fails, crashes.
>
> Any guidance here?
>
> regards, Richard
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/bc9965b7-f37c-4aae-ba31-5897c05bbf13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.