The first thing to know about Ansible is that it changes constantly. New versions with exciting features are released regularly, and it shows no sign of slowing down whatsoever. There is a lot of excitement around this technology, so it's regularly improving. The reason I'm bringing this up is that many distributions often offer an older version of Ansible in their repositories, with Ubuntu being no exception. This means that if you simply run apt install ansible to get the software from Ubuntu's repositories, you may get an older version, and that version may not work with example solutions you find online. I think it's better to get the software from the developers themselves.
The examples in this book were created with Ansible 2.5 in mind. However, depending on when you are reading this, a new version is most likely available...