php - Ansible mysql_user module not accepting encrypted password -
while writing playbook setup mysql , adminer i'm running problem adding encrypted root password.
when using plain text password , not including encrypted=yes
seems work.
i'd include encrypted password [select password('test')]
in playbook.
as can see code below i've added encrypted password in password field , ~/.my.cnf
file , added encrypted=yes
play.
but after running playbook error. please me figure out i'm making mistake or point me appropriate documentation or fix. i've searched stackexchange network , looked @ official documentation ansible , mysql_user module no luck.
system: debian 8.1
error message:
msg: unsupported parameter module: encrypted
playbook code:
--- - hosts: databases remote_user: admin sudo: yes tasks: #get current hostname - name: getting current hostname. raw: "hostname" register: current_hostname # update installed packages latest version - name: update installed packages latest version. apt: upgrade=dist update_cache=yes # installing software - name: installing http server. apt: name=apache2 state=latest - name: installing mysql server. apt: name={{ item }} state=latest with_items: - mysql-server - python-mysqldb - name: start mysql service service: name: mysql state: started enabled: true - name: update mysql root password root accounts mysql_user: name=root host={{ item }} password="*94bdcebe19083ce2a1f959fd02f964c7af4cfc29" encrypted=yes login_user=root login_password="" check_implicit_admin=yes priv="*.*:all,grant" with_items: - "{{ current_hostname.stdout }}" - 127.0.0.1 - ::1 - localhost - name: copy root credentials .my.cnf file template: src=files/home/admin/my.cnf dest=~/.my.cnf mode=0600 - name: installing php5 apt: name={{ item }} state=latest with_items: - php5 - php5-mysql # config adminer - name: making new adminer folder file: path=/usr/share/adminer state=directory - name: downloading latest version of adminer command: 'wget "http://www.adminer.org/latest.php" -o /usr/share/adminer/latest.php' - name: making symbolic link. latest.php --> adminer.php file: path=/usr/share/adminer/adminer.php src=/usr/share/adminer/latest.php state=link - name: writing alias apache2 adminer.conf raw: 'echo "alias /adminer.php /usr/share/adminer/adminer.php" | sudo tee /etc/apache2/conf-available/adminer.conf' - name: enabling adminer.conf in apache2 command: 'a2enconf adminer.conf' - name: restarting apache2 command: '/etc/init.d/apache2 restart'
my ~/.my.conf
file looks this
[client] user=root password=*94bdcebe19083ce2a1f959fd02f964c7af4cfc29
-----------------original questions ends here-----------------
with of @ydaetskcor below , users in comment section able figure out problem ansible 1.7 (default in debian 8.1) not having encrypted module. able work around using command module.
my working code:
--- - hosts: database remote_user: admin sudo: yes tasks: #get current hostname - name: getting current hostname. command: hostname register: current_hostname # update installed packages latest version - name: update installed packages latest version. apt: upgrade=dist update_cache=yes # installing software - name: installing http server. apt: name=apache2 state=latest - name: installing mysql server. apt: name={{ item }} state=latest with_items: - mysql-server - python-mysqldb - name: start mysql service service: name: mysql state: started enabled: true - name: check if root pass blank shell: mysql -u root -e ";" register: blank_root_pass failed_when: false - name: update mysql root password root accounts shell: mysql -u root -e "set password 'root'@'{{ item }}' = '*94bdcebe19083ce2a1f959fd02f964c7af4cfc29';" with_items: - "{{ current_hostname.stdout }}" - 127.0.0.1 - ::1 - localhost when: 'blank_root_pass.stderr==""' - name: installing php5 apt: name={{ item }} state=latest with_items: - php5 - php5-mysql # config adminer - name: making new adminer folder file: path=/usr/share/adminer state=directory - name: downloading latest version of adminer command: 'wget "http://www.adminer.org/latest.php" -o /usr/share/adminer/latest.php' - name: making symbolic link. latest.php --> adminer.php file: path=/usr/share/adminer/adminer.php src=/usr/share/adminer/latest.php state=link - name: writing alias apache2 adminer.conf shell: 'echo "alias /adminer.php /usr/share/adminer/adminer.php" | sudo tee /etc/apache2/conf-available/adminer.conf' - name: enabling adminer.conf in apache2 command: 'a2enconf adminer.conf' - name: restarting apache2 command: '/etc/init.d/apache2 restart'
if see dangerous or out of place, please leave comment. please stop editing call feedback out.
as udondan mentioned, encrypted option mysql_user
added in ansible 2.0.
obviously if upgrade ansible 2.0 can use right now.
alternatively have add user directly via shell module.
- name: check if root pass blank shell: mysql -uroot -e ";" register: blank_root_pass failed_when: false changed_when: false ######################################################## - name: update mysql root password root accounts shell: mysql -uroot -e "set password 'root'@'{{ item }}' = '*94bdcebe19083ce2a1f959fd02f964c7af4cfc29';" with_items: - "{{ current_hostname.stdout }}" - 127.0.0.1 - ::1 - localhost #error 1045 returned when unable login user/pass combo when: 'error 1045' in blank_root_pass.stderr
i've added preliminary check root password in fact blank , used condition second task. logging in root , changing password second task fail on second run without check.
Comments
Post a Comment