Skip to content

Instantly share code, notes, and snippets.

@geoffgarside
Last active February 18, 2016 21:36
Show Gist options
  • Save geoffgarside/0add43139953d093203d to your computer and use it in GitHub Desktop.
Save geoffgarside/0add43139953d093203d to your computer and use it in GitHub Desktop.
---
hosts: server
tasks:
- name: create my.cnf file
copy: >
src=my.cnf dest=/var/db/mysql/my.cnf
owner=mysql group=mysql mode=0644
force=no
- name: configure my.cnf
lineinfile:
dest: /var/db/mysql/my.cnf
insertafter: "[mysqld]"
regexp: "^{{ item.key }}\\s*=\\s*"
line: "{{ item.key }} = {{ item.value }}"
with_items:
- key: sql_mode
value: STRICT_ALL_TABLES
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [server]
TASK [mysql : create my.cnf file] **********************************************
ok: [server]
TASK [mysql : configure my.cnf] ************************************************
failed: [server] => (item={'value': u'STRICT_ALL_TABLES', 'key': u'sql_mode'}) => {"failed": true, "item": {"key": "sql_mode", "value": "STRICT_ALL_TABLES"}, "msg": "Destination /var/db/mysql/my.cnf does not exist !", "rc": 257}
PLAY ***************************************************************************
TASK [setup] *******************************************************************
<188.166.158.192> ESTABLISH SSH CONNECTION FOR USER: ansible
<188.166.158.192> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/Users/geoffgarside/.ansible/cp/ansible-ssh-%h-%p-%r 188.166.158.192 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-nbncfnpoztaqjmdkqhlacjeupvdjvdpo; /bin/sh -c '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'LANG=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 /usr/local/bin/python2.7'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"''"'"'"'"'"'"'"'"''"'"''
ok: [server]
TASK [mysql : create my.cnf file] **********************************************
task path: tasks/main.yml:62
<188.166.158.192> ESTABLISH SSH CONNECTION FOR USER: ansible
<188.166.158.192> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/Users/geoffgarside/.ansible/cp/ansible-ssh-%h-%p-%r -tt 188.166.158.192 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-ztxegrvyayjttkxsedlskceqwlrszmjr; /bin/sh -c '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'rc=flag; [ -r /var/db/mysql/my.cnf ] || rc=2; [ -f /var/db/mysql/my.cnf ] || rc=1; [ -d /var/db/mysql/my.cnf ] && rc=3; /usr/local/bin/python2.7 -V 2>/dev/null || rc=4; [ x"$rc" != "xflag" ] && echo "${rc} "/var/db/mysql/my.cnf && exit 0; (/usr/local/bin/python2.7 -c '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1();
afile = open("'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'/var/db/mysql/my.cnf'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'", "rb")
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(BLOCKSIZE)
afile.close()
print(hasher.hexdigest())'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"' 2>/dev/null) || (/usr/local/bin/python2.7 -c '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'import sha; BLOCKSIZE = 65536; hasher = sha.sha();
afile = open("'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'/var/db/mysql/my.cnf'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'", "rb")
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(BLOCKSIZE)
afile.close()
print(hasher.hexdigest())'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"' 2>/dev/null) || (echo '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'0 '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'/var/db/mysql/my.cnf)'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"''"'"'"'"'"'"'"'"''"'"''
ok: [server] => {"changed": false, "dest": "/var/db/mysql/my.cnf", "invocation": {"module_args": {"dest": "/var/db/mysql/my.cnf", "force": "no", "src": "my.cnf"}, "module_name": "copy"}, "src": "files/my.cnf"}
TASK [mysql : configure my.cnf] ************************************************
task path: tasks/main.yml:67
<188.166.158.192> ESTABLISH SSH CONNECTION FOR USER: ansible
<188.166.158.192> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/Users/geoffgarside/.ansible/cp/ansible-ssh-%h-%p-%r 188.166.158.192 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-hiaxuxjmlkqqsortsftxfyzoocdpfrtc; /bin/sh -c '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'LANG=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 /usr/local/bin/python2.7'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"''"'"'"'"'"'"'"'"''"'"''
failed: [server] => (item={'value': u'STRICT_ALL_TABLES', 'key': u'sql_mode'}) => {"failed": true, "invocation": {"module_args": {"backrefs": false, "backup": false, "content": null, "create": false, "delimiter": null, "dest": "/var/db/mysql/my.cnf", "directory_mode": null, "follow": false, "force": null, "group": null, "insertafter": "[mysqld]", "insertbefore": null, "line": "sql_mode = STRICT_ALL_TABLES", "mode": null, "owner": null, "regexp": "^sql_mode\\s*=\\s*", "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": null, "state": "present", "validate": null}, "module_name": "lineinfile"}, "item": {"key": "sql_mode", "value": "STRICT_ALL_TABLES"}, "msg": "Destination /var/db/mysql/my.cnf does not exist !", "rc": 257}
NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @server.retry
PLAY RECAP *********************************************************************
server : ok=2 changed=0 unreachable=0 failed=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment